R 矩阵创建失败

R 矩阵创建失败,r,matrix,creation,R,Matrix,Creation,命令 a=矩阵(C(1,2,3,4),nrow=2,ncol=2) 返回[r]中的以下错误: C(1,2,3,4)中的错误:对象不能解释为因子 这让我很奇怪为什么?在c(1,2,3,4)中的c必须是小写的 > a = matrix( C(1,2,3,4), nrow=2, ncol=2) Error in C(1, 2, 3, 4) : object not interpretable as a factor > a = matrix( c(1,2,3,4), nrow=2, nco

命令

a=矩阵(C(1,2,3,4),nrow=2,ncol=2)

返回[r]中的以下错误:

C(1,2,3,4)中的错误:对象不能解释为因子


这让我很奇怪为什么?

c(1,2,3,4)
中的
c
必须是小写的

> a = matrix( C(1,2,3,4), nrow=2, ncol=2)
Error in C(1, 2, 3, 4) : object not interpretable as a factor
> a = matrix( c(1,2,3,4), nrow=2, ncol=2)
> a
     [,1] [,2]
[1,]    1    3
[2,]    2    4

试试
c
而不是
c
谢谢!这样一个愚蠢的错误,我20分钟都找不到。R区分大小写,用
c
代替
c