R Function List
Statistics
sum
min
, max
length
mean
median
var
sd
standard deviation
cor
lm
linear model
summary
coef
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
vector
vector("numeric", length = 10)
generates a vector having 10 zeros
seq([from =] a, [to =] b, [by =] stepsize)
seq(1,10,3)
Matrix
matrix(data,nrow,ncol)
rbind(first_row, second_row, ...)
cbind(first_column, second_column, ...)
solve
can give the inverse of the matrix
dim
- A matrix can be created directly from a vector by adding a dimension attribute
# Turn a vector into a matrix by adding a dimension attribute
m <- 1:10
dim(m) <- c(2,5)
m
Manipulation
sort
head(vec,n)
tail(vec,n)
x <- c(6, 8, 7, 5, 3, 0, 9)
head(x,2)
tail(x,3)
For Matrices
Logic
- The argument of the below functions is conditional expressions
which
any
x <- c(6, 8, 7, 5, 3, 0, 9)
which(x %% 2 == 0) # return indexes
any(x == 10)
Plot
by zcysxy