gpt4 book ai didi

r - 从 reshape2 帮助页面运行示例时出现错误消息

转载 作者:行者123 更新时间:2023-12-02 01:39:25 25 4
gpt4 key购买 nike

我的代码之前运行没有问题,但在调用 dcast 公式时崩溃了。经过一番尝试,我发现即使是 dcast 帮助页面中的最小示例也不再适合我了。更准确地说:

#Air quality example
names(airquality) <- tolower(names(airquality))
aqm <- melt(airquality, id=c("month", "day"), na.rm=TRUE)

acast(aqm, day ~ month ~ variable)
acast(aqm, month ~ variable, mean)

最后一行产生以下错误:

Error in vaggregate(.value = value, .group = overall, .fun = fun.aggregate,  : 
could not find function ".fun"

这是我的 sessionInfo():

R version 2.13.1 (2011-07-08)
Platform: x86_64-pc-mingw32/x64 (64-bit)

locale:
[1] C

attached base packages:
[1] grid stats graphics grDevices utils datasets methods base

other attached packages:
[1] ggplot2_0.8.9 proto_0.3-9.2 reshape2_1.1 xtable_1.5-6 reshape_0.8.4 plyr_1.5.2 lubridate_0.2.5

loaded via a namespace (and not attached):
[1] stringr_0.5 tools_2.13.1

对于这里出现的问题,我没有给出令人满意的答案,所以我希望得到一些帮助。另外,我在 stackoverflow 上找到了以下线程:Similar problem这个问题似乎是由自定义函数引起的。但是,我使用标准均值函数和帮助页面中的标准示例。

更新:我刚刚做了一些互联网研究,没有找到任何有关 reshape2 软件包更新的信息。这是我对这个问题的最佳猜测。

UPDATE2:出现这个问题是因为我很可能在 R session 期间玩弄统计示例时重新分配了均值函数。重新启动R解决了这个问题。现在,一切再次按预期进行。

最佳答案

为了完整性:

PaulHurleyuk 的评论:

Have you tried restarting R and trying the example in a fresh session ? Or do rm(list=ls()) to remove everything from the current session. In the past I have managed to break things by assigning something to something that shouldn't be assigned to.

Christoph_J 的回复:

Thanks ... that was exactly the problem...

The problem occurred because I most probably reassigned the mean function while I was playing around with a statisctic example during an R session. Restarting R solved the problem. Now, everything works as expected again.

关于r - 从 reshape2 帮助页面运行示例时出现错误消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7082792/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com