Error in ** : incorrect number of dimensions
目录
Error in ** : incorrect number of dimensions
问题:
#向量是一维的,尝试使用二维数据集来进行索引,当然不行;
#
#define vector
x <- c(3, 4, 7, 7, 14, 19, 22, 28, 29, 30)
#attempt to access value in first row and third column
x[ , 3]
#attempt to access value in third row and first column
x[3, ]
解决:
#按照一维的方式来索引
#access third value in vector
x[3]
#access values in positions 2 through 5
x[2:5]
完整错误:
> #define vector
> x <- c(3, 4, 7, 7, 14, 19, 22, 28, 29, 30)
>
> #attempt to access value in first row and third column
> x[ , 3]
Error in x[, 3] : incorrect number of dimensions
>
> #attempt to access value in third row and first column
> x[3, ]
Error in x[3, ] : incorrect number of dimensions
>