R语言数据类型转换

时间:2021-05-29 11:57:09
test for data type
is.numeric(), is.character(), is.vector(), is.matrix(), is.data.frame()

convert it
as.numeric(), as.character(), as.vector(), as.matrix(), as.data.frame)

vector/matrix/data.frame

  to one long
vector
to
matrix
to
data frame
from
vector
c(x,y) cbind(x,y)
rbind(x,y)
data.frame(x,y)
from
matrix
as.vector(mymatrix)   as.data.frame(mymatrix)
from
data frame
  as.matrix(myframe)