[英]Please, What does this error mean in R Studio?
Error in `$<-.data.frame`(`*tmp*`, residuals, value = c(`1` = 85.2823496546331, : replacement has 64 rows, data has 999
3.
stop(sprintf(ngettext(N, "replacement has %d row, data has %d", "replacement has %d rows, data has %d"), N, nrows), domain = NA)
2.
`$<-.data.frame`(`*tmp*`, residuals, value = c(`1` = 85.2823496546331, `2` = 75.6452252037355, `3` = -26.6646054332669, `4` = 53.1072802045741, `5` = 45.2947706852716, `6` = 0.109746902327331, `7` = -90.2459997479568, `8` = -56.514561514735, `9` = -9.18563164550705, `10` = -58.4067912439267, ...
1.
`$<-`(`*tmp*`, residuals, value = c(`1` = 85.2823496546331, `2` = 75.6452252037355, `3` = -26.6646054332669, `4` = 53.1072802045741, `5` = 45.2947706852716, `6` = 0.109746902327331, `7` = -90.2459997479568, `8` = -56.514561514735, `9` = -9.18563164550705, `10` = -58.4067912439267, `11` = -14.1825622165646, ...
The error is very clear - replacement has 64 rows, data has 999
.错误很明显 -
replacement has 64 rows, data has 999
。
This means that at some place in your code (I can't tell you where as you have not posted it) you are attempting to replace only parts of an object.这意味着在你的代码中的某个地方(我不能告诉你在哪里,因为你没有发布它)你试图只替换对象的一部分。
Here is an example of what you are attempting to do, based on some example data:以下是您尝试执行的操作的示例,基于一些示例数据:
# Make a dataframe with 10 rows in it
df = data.frame(A = 1:10, B = 1:10+1)
df
#> A B
#> 1 1 2
#> 2 2 3
#> 3 3 4
#> 4 4 5
#> 5 5 6
#> 6 6 7
#> 7 7 8
#> 8 8 9
#> 9 9 10
#> 10 10 11
If you try to assign one of the rows with a different length vector or set of values, you will get the error.如果您尝试分配具有不同长度向量或一组值的行之一,则会出现错误。
df$A = c(1,2,3)
#> Error in `$<-.data.frame`(`*tmp*`, A, value = c(1, 2, 3)): replacement has 3 rows, data has 10
If you instead try to change the column to a vector of equal length, it will work.如果您尝试将列更改为等长的向量,它将起作用。
df$A <- c(1,1,1,1,1,1,1,1,1,1)
df
#> A B
#> 1 1 2
#> 2 1 3
#> 3 1 4
#> 4 1 5
#> 5 1 6
#> 6 1 7
#> 7 1 8
#> 8 1 9
#> 9 1 10
#> 10 1 11
To summarise, make sure that you are using the correct objects.总而言之,请确保您使用的是正确的对象。
Created on 2020-11-17 by the reprex package (v0.3.0)由reprex 包(v0.3.0) 于 2020 年 11 月 17 日创建
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.