?aggregate 文档中的示例生成错误
为什么这对我不起作用:
我从 R 帮助中粘贴了以下示例:
aggregate(. ~ Species, data = iris, mean)
我每次都会收到以下错误
Error in m[[2L]][[2L]] <- parse(text = lhs)[[1L]] :
object of type 'symbol' is not subsettable
但是以下有效:
aggregate(len ~ ., data = ToothGrowth, mean)
令人惊讶...
编辑:提供了会话信息
> sessionInfo()
R version 2.12.2 (2011-02-25)
Platform: x86_64-pc-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252
attached base packages:
[1] splines stats graphics grDevices utils datasets methods base
other attached packages:
[1] doBy_4.4.0 MASS_7.3-11 snow_0.3-6 lme4_0.999375-39 Matrix_0.999375-46 lattice_0.19-17
[7] multcomp_1.2-6 mvtnorm_0.9-96 R2HTML_2.2 survival_2.36-5 reshape_0.8.4 plyr_1.4
[13] rcom_2.2-3.1 rscproxy_1.3-1 Biostrings_2.18.4 IRanges_1.8.9
loaded via a namespace (and not attached):
[1] Biobase_2.10.0 grid_2.12.2 nlme_3.1-98 stats4_2.12.2 tools_2.12.2
Why is this not working for me:
I pasted in the following example from R help:
aggregate(. ~ Species, data = iris, mean)
I am getting following error every time
Error in m[[2L]][[2L]] <- parse(text = lhs)[[1L]] :
object of type 'symbol' is not subsettable
However the following works:
aggregate(len ~ ., data = ToothGrowth, mean)
Surprised ...
Edits: session information is provided
> sessionInfo()
R version 2.12.2 (2011-02-25)
Platform: x86_64-pc-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252
attached base packages:
[1] splines stats graphics grDevices utils datasets methods base
other attached packages:
[1] doBy_4.4.0 MASS_7.3-11 snow_0.3-6 lme4_0.999375-39 Matrix_0.999375-46 lattice_0.19-17
[7] multcomp_1.2-6 mvtnorm_0.9-96 R2HTML_2.2 survival_2.36-5 reshape_0.8.4 plyr_1.4
[13] rcom_2.2-3.1 rscproxy_1.3-1 Biostrings_2.18.4 IRanges_1.8.9
loaded via a namespace (and not attached):
[1] Biobase_2.10.0 grid_2.12.2 nlme_3.1-98 stats4_2.12.2 tools_2.12.2
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这个问题已经部分解决了。我使用了一个新的 R 会话,粘贴了代码并得到了我想要的。可能是包或我在会话中定义的东西导致了问题(我不知道),如此处建议的,请参阅prov。
This question is partially solved. I used a fresh R session, pasted code and got what I want. Potentially the package or something I define in the session are causing problem ( I do not know), as suggested here see prov.