install.packages(“packageName”)
: download and install a package –> start R as following: Rgui.exe –internet2
help(package=XML)
: information about the package XML
str(a)
: display the structure of a object
table(x)
: returns a table with the numbers of the different values of x
[]
: subscript a string
as.matrix.data.frame(
data)
: convert data to a matrix
image.plot(
x, y, matrix)
: color matrix (library(filds))
attach, detach
: open/close table
read.table(…)
:
skip=n
: begin to read rows after n rows
row.names=n
: the row names are in column n or a vector giving the actual row names
nrows=n
: read maximal n rows
fill=TRUE
: show missing values
na.strings=“
N.A.”
: transform N.A. in NA (missing values)
for(i in 1:ncol(
data)) if(is.numeric(
data[,i]))
data[is.na(
data[,i]),i] ← 0
: transform all NA to 0
object ← cbind(
object, as.matrix(“newColumn”))
: add new column or row(rbind
) to an existing matrix
byrow=TRUE
(in matrix): makes the matrix row by row (instead of column by column)
legend.lab
: write a legend in image.plot