是一类特殊向量,维度属性:长度2的整形向量:行数nrow列数ncol
args(matrix)
## function (data = NA, nrow = 1, ncol = 1, byrow = FALSE, dimnames = NULL)
## NULL
m<-matrix (nr ow=2, ncol=3, dimnames=list (c "行1","行2”),c(“列1”,“列2”,“列3”)));m
# 列 1 列2 列3
# 行 1 N4 N4 N4
# 行2 NA NA NA
dim(m) #查看维度,也可用: attributes (m)
## [1] 2 3
m<- ma t r i x (1 : 6, nrow=2, ncol =3, byrow=F) ;#默认按列排列
m<- 1 : 6 ; dim (m) <- c (2, 3) ;m #通过 dim()对向量创建矩阵