Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Some R packages do not update with update.packages()

Tags:

r

Selecting Packages->Update packages... gave:

> update.packages(ask='graphics',checkBuilt=TRUE)
--- Please select a CRAN mirror for use in this session ---
Warning: package 'foreign' in library 'C:/Program Files/R/R-3.0.2/library' will not be updated
Warning: package 'lattice' in library 'C:/Program Files/R/R-3.0.2/library' will not be updated
Warning: package 'Matrix' in library 'C:/Program Files/R/R-3.0.2/library' will not be updated
Warning: package 'mgcv' in library 'C:/Program Files/R/R-3.0.2/library' will not be updated
Warning: package 'nlme' in library 'C:/Program Files/R/R-3.0.2/library' will not be updated
Warning: package 'rpart' in library 'C:/Program Files/R/R-3.0.2/library' will not be updated

I ran the R shortcut in the startup menu "as Administrator" and got the same results.

R version is 3.0.2.

like image 880
antonio Avatar asked Dec 14 '13 19:12

antonio


People also ask

How do I update a package in R?

If you only want to update a single package, the best way to do it is using install. packages() again. In RStudio, you can also manage packages using Tools -> Install Packages.

Does R automatically update packages?

As far as I know, there are no automatic updates for R, RStudio and packages. And as updates are quite frequent, it is quite a hassle to check every few weeks (or even days) if there are new versions available.

Should I update packages in R?

If you're updating R itself, you should update your packages. Depending on your installation, R will make a new directory for packages anyway, so you either have to relink your old set or reinstall them. If you're going to relink, update and rebuild, or you'll likely get a lot of annoying warnings later to do so.


4 Answers

A general restatement of the question

  1. In Windows 7/8 the package nicePack, included in the base install, is outdated.
  2. You update it with update.packages() or via the equivalent GUI menu.
  3. You get:
    Warning: package 'nicePack' in library 'C:/Program Files/R/R-3.*.*/library" will not be updated

Potential causes

R is not very kind with Windows so it just says "will not be updated" and not something like "permission denied to C:/Program Files/R/...". Anyway you realise that R cannot write to C:/Program Files and so restart it as Administrator and upgrade, but the problem persists!

If you check the personal package directory, where R is able to write, you see that the updated version of nicePack is there. In Windows the directory is normally ~\R\win-library\x.y or find it with Sys.getenv("R_LIBS_USER").

Probably the first time R, unable to write to R default directory, used the personal directory, so that there are two versions of nicePack. The second time, despite the admin privileges, R finds the updated package version in the personal directory and it does not update the default directory.

May be that R says "warning" and not "error", because the package is installed in the personal directory, but an outdated version remains in the default library.

Solution

Delete nicePack package directory in the personal library directory, restart as administrator and update again.

Opinions

I don't know if there is an actual bug in this behaviour, anyway more informative messages would for sure help the Windows user.

Perhaps the default library should be avoided in Windows, in favour of the personal. Many Windows applications use C:\ProgramData or ~\AppData\Local, writeable without special privileges.

like image 142
antonio Avatar answered Nov 14 '22 07:11

antonio


I am on Ubuntu and i have the same problem from RStudio. I have tried to solve by sudo R and update.packages(). But it did not help. However sudo rstudio + update.packages() have solved the problem.

like image 26
vondoRishi Avatar answered Nov 14 '22 08:11

vondoRishi


On R 4.0.4 (Gallium OS 3.1)

Permissions? old.packages() ?

In my case, I noticed 3 packages that would not update had permissions set differently from others in /usr/local/lib/R/library.

I fixed the permissions, but this did not solve the problem.

Then I ran old.packages() and noted the SAME 3 packages were considered old.

I admit I did not quite understand the help in ?update.packages(), but tried the following.

update.packages(oldPkgs = old.packages())

This fixed the problem and the 3 packages updated.

like image 32
jim rothstein Avatar answered Nov 14 '22 07:11

jim rothstein


In my case worked the following command sequence in the Terminal of Ubuntu:

sudo i-
R
update.packages(ask=FALSE)
q(save="no")
logout

That is to say: loging as root -> starting R -> updating packages from root -> out of R -> out of root.

like image 34
Miguel Alvarez Avatar answered Nov 14 '22 06:11

Miguel Alvarez