Error in *** : subscript out of bounds

Posted Data+Science+Insight

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Error in *** : subscript out of bounds相关的知识,希望对你有一定的参考价值。

Error in *** : subscript out of bounds

目录

Error in *** : subscript out of bounds

问题:

解决:

完整错误:


问题:

数据越界了啊,除了别介,谁知道那是在哪里?你问内存?内存问谁?

#make this example reproducible
set.seed(0)

#create matrix with 10 rows and 3 columns
x = matrix(data = sample.int(100, 30), nrow = 10, ncol = 3)

#print matrix
print(x)

#attempt to display 11th row of matrix
x[11, ]

#attempt to display 4th column of matrix
x[, 4]

#attempt to display value in 11th row and 4th column
x[11, 4]

解决:

#

#display number of rows and columns in matrix
dim(x)

#

#display 10th row of matrix
x[10, ]

#display number of columns in matrix
ncol(x)

#display 3rd column of matrix
x[, 3]

#display value in 10th row and 3rd column of matrix
x[10, 3]

完整错误:


> #attempt to display 11th row of matrix
> x[11, ]
Error in x[11, ] : subscript out of bounds

> #attempt to display 4th column of matrix
> x[, 4]
Error in x[, 4] : subscript out of bounds

> #attempt to display value in 11th row and 4th column
> x[11, 4]
Error in x[11, 4] : subscript out of bounds

以上是关于Error in *** : subscript out of bounds的主要内容,如果未能解决你的问题,请参考以下文章

R Error in :missing values are not allowed in subscripted assignments of data frames

R语言报错:Error in psi[j, t] <- which.max(preProb) : subscript out of bounds

Unity 报错解决方法:Standard Shader Invalid Subscript uv2 error

"error": "无法连接到 websocket 端点 ws://localhost:8000/subscriptions。请检查端点 url 是不是正确。"

c++中,error C2369: 'y' : redefinition; different subscripts

Unity 报错解决方法:Standard Shader Invalid Subscript uv2 error