These are the R functions that we primarily use in SE350:

Function Description
getwd() Get the working directory path
setwd() Set Working Directory
dir() Show the names of the files in the working directory (or folder)
ls() List all object in workspace
read.csv(file,as.is=TRUE) Import Data from a Comma Seperated Value file
dim(object) Give dimensions of an object
summary(data) Provide a summary of an object
class(object) Give the class of an object (i.e. character, numeric, etc)
as.factor(character object) Coerce a Characer object to Factor
as.character(object) Coerce a factor object to character
plot(x,y) Plot x and y
c(object1, object2, object3….) Create a vector of objects
rep(x,rep=) Repeat x a certain number of times
data.frame() Build a data frame with a number of fectors
names(dataframe) Give names of the data.frame
head(dataframe) Give the first 5 lines of the data frame
subset(data,formula) Subset data by a boolean expression (i.e. Gender==“Male”)
table(x) Provide a table of x
pie(table) Plot a pie chart of a table
barplot(table) Plot a barplot of a table
aggregate(x~y,data,function) Aggregate x by y given a function (mean, sum , etc)
hist(x) Plot a historgram of x
boxplot(x) Plot a boxplot of x
pairs(numeric columns of a data table) Produce a pairs plot of
cor(x,y) Correlation of X and Y
lm(x,y,data) Linear Model of x and y from data
abline(lm.model) Add a regression trendline from lm.model to a plot
summary(lm.model) Get the basic statistics from lm.model
predict(lm.model, newdata) Predict with newday on lm.model