-2

I have been trying to get the summaryBy function to work but can't seem to get it on R. I have looked though various forums and used the tips given but still can't get it to work. Any help would be greatly appreciated. I am a novice to R so I may be making a simple error but I have tried to cover off all the suggestions from other forums. My code looks like this:

> 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

Then

> 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’

Can anyone see why it doesn't work?

Thanks

Ben Bolker
  • 211,554
  • 25
  • 370
  • 453
Dechlan
  • 1
  • 1
  • 1

1 Answers1

1

Remember, you installed a package called doBy, which includes a function called summaryBy. You install a package, you require a package, but you call a function.

So you should do:

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

You can also use library() instead of require(). Either way works, though they differ in their response to packages that are not found. More here.

wxl
  • 246
  • 3
  • 10