q()— quit the program.
control-c— stop R if it's doing something you don't want it to.
apropos('some topic')— find out about some topic (must be quoted).
help(command)— find out about some command.
?command— same as above.
dir()— list the contents of the current directory.
getwd()— get the current working directory.
setwd()— set the current working directory (or use the Misc menu in the GUI).
2 + 3 6 / 2 7 * 34 8^3 sum(2,7,3)
a <- 4 a 2 * a b <- 7 b + a
c(3,6,27,2) c(4,9,4)^2 a <- c(4,9,4) a / c(2,5,4) a / c(2,5) b <- 2:8 c(a,b) c('a','b')
data.frame()— a vector of vectors, the standard format for data for statistical analysis. (All the vectors must be of the same length.)
age <- c(25,30,56,22,17,9) gender <- c("m","f","m","m","f","f") weight <- c(160,110,220,150,90,100) major <- c('ling','comm','comm','ling','ling','ling') g <- data.frame(age,gender,weight,major)Notice that words or strings must be quoted; single or double quotes will work.
fix()— alter a statistical object by typing it in with the R editor.
g <- data.frame(age=numeric(0), gender=character(0), weight=numeric(0), major=character(0)) fix(g)
read.table()— read in a text file and make a dataframe object from it.
g <- read.table('gender.txt',header=T)Note that the file must be a real text file and must be located in the current working directory.