错误:无法找到功能" summaryBy"在R

时间:2014-09-06 16:42:33

标签: r

我一直在努力让summaryBy功能正常工作,但似乎无法在R上找到它。我已经查看了各种论坛并使用了给出的提示但仍无法使其工作。任何帮助将不胜感激。我是R的新手所以我可能会犯一个简单的错误,但我试图掩盖其他论坛的所有建议。我的代码如下所示:

> install.packages("doBy", dependencies = TRUE)
Installing package into ‘C:/Users/Dechlan/Documents/R/win-library/3.0’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
trying URL 'http://star-www.st-andrews.ac.uk/cran/bin/windows/contrib/3.0/doBy_4.5-10.zip'
Content type 'application/zip' length 2634327 bytes (2.5 Mb)
opened URL
downloaded 2.5 Mb

package ‘doBy’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
     C:\Users\Dechlan\AppData\Local\Temp\RtmpqOhjyD\downloaded_packages

然后

> summaryBy(A, data = testdata2, id = good)
Error: could not find function "summaryBy"
> require(summaryBy)
Loading required package: summaryBy
Warning message:
In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE,  :
  there is no package called ‘summaryBy’

谁能明白为什么它不起作用?

由于

1 个答案:

答案 0 :(得分:1)

请记住,您安装了名为doBy,其中包含名为summaryBy功能。你安装一个包,你需要一个包,但你调用一个函数。

所以你应该这样做:

install.packages("doBy")
require(doBy)            # note the difference!
summaryBy(...)

您也可以使用library()代替require()。无论哪种方式都有效,尽管它们对未找到的包的响应不同。更多here