R Notes


Case sensitive

Database connectivity


Install packages on locked down installation:

.libPaths(c(“C:\\Users\\lross\\R\\library”, .libPaths()))

Manually unzip required packages into above path, then you can use as normal

e.g. library(openxlsx)

alternate: library(ggplot2, lib.loc=”/data/Rpackages/”)

Unload package:


Clear workspace (Default action at start of a file?)


Merging Data
Adding Columns
To merge two data frames (datasets) horizontally, use the merge function. In most cases, you join two data frames by one or more common key variables (i.e., an inner join).

# merge two data frames by ID
total <- merge(data frameA,data frameB,by=”ID”)

# merge two data frames by ID and Country
total <- merge(data frameA,data frameB,by=c(“ID”,”Country”))

Add column to Data Frame

Add column to dataframe, combined with vector (row) operation

mtcars1 <- mtcars
mtcars1$x <- mtcars1$gear * mtcars1$carb




Posted in R