R summary PS 17 June 2011) #help for help on any function type ?function_name e.g. ?title, ?read.table # variable assignment and types example <- c(1,2,3) # assigns a vector containing numbers 1,2,3 to 'example' # data import and manipulation read.table(file, header = FALSE, sep = "", quote = "\"'", dec = ".", row.names, col.names, as.is = !stringsAsFactors, na.strings = "NA", colClasses = NA, nrows = -1, skip = 0, check.names = TRUE, fill = !blank.lines.skip, strip.white = FALSE, blank.lines.skip = TRUE, comment.char = "#", allowEscapes = FALSE, flush = FALSE, stringsAsFactors = default.stringsAsFactors(), fileEncoding = "", encoding = "unknown") # file: path to file to be imported; use file.choose() to open dialog window to choose file from finder # header = TRUE/FALSE : if file has header or not # sep = '' : optional; by default any whitespace is used to separate columns; use 'sep' to define which character is used to split (e.g. '\t' for just tabs) # fill = TRUE/FALSE : if TRUE then in case the rows have unequal length, blank fields are implicitly added; FALSE by default table$column : select column from table (default column names are V1, V2, V3, etc; if header is specified colunms have the specified names) # subset subset(x, subset, select) # x: object to be subsetted # subset: logical expression indicating elements or rows to keep # select: #### PACKAGES #installing packages from repositories install.packages('package_name') # installing packages from source install.packages('path_to_package.tar.gz', repos=NULL, type="source") # load package library('package_name')