?aggregate 文档中的示例生成错误

发布于 2024-12-05 13:02:06 字数 1285 浏览 2 评论 0原文

为什么这对我不起作用:

我从 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦开始←不甜 2024-12-12 13:02:06

这个问题已经部分解决了。我使用了一个新的 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文