Level 2 Level 4
Level 3

Managing variables and objects


42 words 0 ignored

Ready to learn       Ready to review

Ignore words

Check the boxes below to ignore/unignore words, then click save at the bottom. Ignored words will never appear in any learning session.

All None

Ignore?
ls()
lists all the user objects
rm(Object)
removes Object
rm(list=ls())
remove all user objects
save(Object, file=Filename)
save Object to file Filename
save.image(Filename)
save the entire workspace to Filename
load(Filename)
load the R objects in file Filename
dim(M)
dimensions of matrix M
dimnames(M)
names of dimensions of matrix M
names(Df)
variable names in data frame Df
length(V)
length of vector V
1:3
sequence of integers 1, 2, 3
c(1, 2, 4)
concatenate 1, 2, 4
seq(from, to, by)
create a sequence from, to by a step
seq(from, to, length=N)
create a sequence from, to of length N
rep(V, N)
repeats the vector V N times like c(V, V, ...)
rep(V, each=N)
repeats the elements of vector V N times like c(V[1], V[1], V[2], V[2], ...)
cbind(C1, C2, C3)
bind columns C1, C2, C3 into a matrix or data frame
rbind(R1, R2, R3)
bind rows R1, R2, R3 into a matrix or data frame
merge(Df1, Df2)
merge data frames Df1 and Df2
matrix(V, nrow, ncol)
make vector V into a matrix with nrow rows and ncol columns
data.frame(var1=V1, var2=V2)
make a data frame with variables var1 and var2 from vectors V1 and V2
ts(V, frequency=4)
creates a time-series object containing values V and with frequency=4 (e.g. a quarterly time series)
ts(M, frequency=4)
creates a multivariate time-series object containing values in matrix M and with frequency=4 (e.g. a quarterly time series)
function(par1, par2){do something}
define a new function in the R language with parameters par1 and par2 (do something in the body)
as.factor(X)
coerce object X (usually a vector) to a factor/categorical varaible (ordered or unordered)
as.matrix(X)
coerce object X to a matrix
as.vector(X)
coerce object X to a vector
as.data.frame(X)
coerce object X to a data frame
is.factor(X)
tests if its argument X is a factor
is.matrix(X)
tests if its argument X is a matrix
is.vector(X)
tests if its argument X is a vector
is.data.frame(X)
tests if its argument X is a data.frame
t(M)
transpose M (a vector, matrix or data frame)
which(V==1)
returns indices of V where V is equal to 1 (V==1)
unique(X)
returns the unique elements in X
union(V1, V2)
perform set union of V1 and V2
setdiff(V1, V2)
perform set asimmetric difference of V1 and V2
intersect(V1, V2)
perform set intersection of V1 and V2
search()
view the search path
attach(Df)
put variables in Df in search path
detach(Df)
remove from search path variables in Df
reshape
name of the function that reshapes a data frame between "wide" and "long" (and viceversa) format. See help files for more details