60

I have always worked with the zoo package, that I have installed a long time ago. Today, I created a new R script, and ran library(zoo) and got the following error:

 > library(zoo)
 Error in library(zoo) : there is no package called ‘zoo’

Odd.. Still, I tried reinstalling the package using install.packages("zoo"), and get the following:

 > install.packages("zoo")
 Installing package(s) into ‘C:/Users/U122337.BOSTONADVISORS/Documents/R/win-library/2.15’
 (as ‘lib’ is unspecified)
 --- Please select a CRAN mirror for use in this session ---
 trying URL 'http://cran.cnr.Berkeley.edu/bin/windows/contrib/2.15/zoo_1.7-10.zip'
 Content type 'application/zip' length 874474 bytes (853 Kb)
 opened URL
 downloaded 853 Kb

 package ‘zoo’ successfully unpacked and MD5 sums checked
 Warning: cannot remove prior installation of package ‘zoo’

The downloaded binary packages are in
    C:\Users\U122337.BOSTONADVISORS\AppData\Local\Temp\Rtmp404t8Y\downloaded_packages

When I try uploading the package, I get the error again that the zoo package doesn't exist.

I have no idea what's happening. I exited the GUI and restarted it, same problem. I have always worked with this package, and I have no idea why this is happening now.

halfer
  • 19,824
  • 17
  • 99
  • 186
Mayou
  • 8,498
  • 16
  • 59
  • 98

5 Answers5

49

Do .libPaths(), close every R runing, check in the first directory, remove the zoo package restart R and install zoo again. Of course you need to have sufficient rights.

statquant
  • 13,672
  • 21
  • 91
  • 162
  • 4
    Worked great! Thanks. Would you know what that happened in the first place? – Mayou Oct 16 '13 at 15:26
  • Worked perfectly for me. I had same issues with package nloptr. Just a caveat: windows gave me a warning stating that R was still using the files, so I had to manually go into windows Task Manager and end all processes related to R (even after closing all R windows) to delete the package files. – theforestecologist Nov 08 '16 at 21:54
9

When you run

install.packages("whatever")

you got message that your binaries are downloaded into temporary location (e.g. The downloaded binary packages are in C:\Users\User_name\AppData\Local\Temp\RtmpC6Y8Yv\downloaded_packages ). Go there. Take binaries (zip file). Copy paste into location which you get from running the code:

.libPaths()

If libPaths shows 2 locations, then paste into second one. Load library:

library(whatever)

Fixed.

M_D
  • 287
  • 3
  • 13
  • What do you mean, paste into second one? – Dave Liu Feb 21 '19 at 22:42
  • 1
    If by runnnign libPaths you get 2 locations, like: ``[1] location/one/something1 ``[2] location/two/seomthing2 then paste binaries copied from link that pops up after installing the package into location/two/seomthing2. It works for me. – M_D Feb 22 '19 at 07:50
  • Thanks! It turns out there's some really weird pathing issues with the Macports version of R, so I completely uninstalled the macports version, updated my dyLD_LIBRARY_PATH and R_HOME, and then installed R using a .pkg, which ended up allowing R to correctly find where the packages were. This helped me track down two different places that the install packages were going. – Dave Liu Feb 22 '19 at 19:36
2

I had this problem and the issue was that I had the package loaded in another R instance. Simply closing all R instances and installing on a fresh instance allowed for the package to be installed.

Generally, you can also install if every remaining instance has never loaded the package as well (even if it installed an old version).

pdb
  • 1,574
  • 12
  • 26
1

So the package will be downloaded in a temp folder C:\Users\U122337.BOSTONADVISORS\AppData\Local\Temp\Rtmp404t8Y\downloaded_packages from where it will be installed into your library folder, e.g. C:\R\library\zoo

What you have to do once install command is done: Open Packages menu -> Load package...

You will see your package on the list. You can automate this: How to load packages in R automatically?

aleksander_si
  • 1,021
  • 10
  • 28
1

go to this folder C:\Users\hp\Documents\R\win-library\4.0 in your PC. And delete '00LOCK' named folder. then It will work properly, THis folder is being locked all incoming file.IF your delete this , then it will work.

K. Gaurav
  • 11
  • 1