R

R Function List

Statistics

x = c(4,6,12,9,21,14)
mean(x)
var(x)
median(x)

y = c(10,13,22,15,30,15)
cor(x,y)

Generation

seq(1,10,3)

Matrix

# Turn a vector into a matrix by adding a dimension attribute
m <- 1:10
dim(m) <- c(2,5)
m

Manipulation

x <- c(6, 8, 7, 5, 3, 0, 9)
head(x,2)
tail(x,3)

For Matrices

Logic

x <- c(6, 8, 7, 5, 3, 0, 9)
which(x %% 2 == 0) # return indexes
any(x == 10)

Plot

Creative Commons License by zcysxy