Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upgrade all standard packages while retaining non-standard packages

Sometimes GNU R has a problem whereby Hadley Wickham recommends:

I'd recommend re-installing all your packages.

The question is how to do this in the best possible way. I know that install.packages or update.packages will upgrade all package versions and overwrite existing versions:

update.packages(checkBuilt = TRUE, ask = FALSE)

When using CRAN packages (nothing special from GitHub or other sources), this naive approach worked for me:

my.packages <- rownames(installed.packages());
install.packages(my.packages);

What can I do if I have installed dev versions from GitHub, for example, or used some local packages that are not shared publicly?

What I am looking for is a way to:

  1. check which changes to packages result from new installation (upgrades/downgrades);
  2. install packages again from the same source; and
  3. back up my old packages folder.

How can I address these requirements?

like image 970
flexponsive Avatar asked Oct 17 '22 17:10

flexponsive


1 Answers

Partial solution for (1) - find out which packages will be upgraded/downgraded:

my.packages <- installed.packages();
my.avail <- available.packages();

z <- merge(
      my.packages[,c("Package","Version")],
      my.avail[,c("Package","Version")],
      by = "Package", suffixes = c('.my','.avail'));

z$Version.my <- as.character(z$Version.my)
z$Version.avail <- as.character(z$Version.avail)

# my packages which will be upgraded
subset(z, Version.my < Version.avail)

# my packages that will be downgraded
subset(z, Version.my > Version.avail)

This is only approximate, I think - depending on dependencies you may not get all the upgrades. But you should see the downgrades to expect if using dev versions?

Another way to upgrade all packages is to use the following:

like image 132
flexponsive Avatar answered Oct 20 '22 05:10

flexponsive