7

I'm using R 3.4.1 on Red Hat Enterprise Linux 6. I have version 3.0 of package asreml installed under /tools/bioinfo/app/R-3.4.1/lib64/R/library.

> library(asreml)
Loading required package: lattice
Checking for license <redacted>

> .libPaths()
[1] "/tools/bioinfo/app/R-3.4.1/lib64/R/library"

Version 4 of that package has now come out, but we would like to compare the results of version 3 with version 4. To that end, we would like to have version4 installed on our system as asreml4. I have downloaded the *tar.gz file with the latest version, but if I do

R CMD INSTALL asreml_4.1.0.93.tar.gz

it installs it in the asreml folder, overwriting the old version. That's not what I want.

I've also tried to install it in another place, rename the folder to asreml4, and copy that folder to /tools/bioinfo/app/R-3.4.1/lib64/R/library and then tried to load it, but then it loads the wrong version:

> library(asreml, lib.loc="/tools/bioinfo/app/R-3.4.1/lib64/R/library/asreml4")
> packageVersion("asreml")
[1] ‘3.0.1’

So, how do I install it in an asreml4folder in such a way that I can call it with library(asreml4)?

BioGeek
  • 21,897
  • 23
  • 83
  • 145
  • 1
    Is `/tools/bioinfo/app/R-3.4.1/lib64/R/library/asreml4` the folder of the package, or is there a `asreml` folder within that? Because `lib.loc` needs to point to the library directory. – Spacedman Sep 21 '18 at 15:59

1 Answers1

7

1) edit DESCRIPTION Download the source, edit the DESCRIPTION file to have a different name and then build and install it.

2) separate library Alternately install the new version into a separate library and then use one of these to get the desired version:

library(asreml, lib = ...)
library(asreml)

2a) .libPaths A variation of this is to use .libPaths(new) to change the default library path, issue

library(asreml)

and then change it back.

2b) dev_mode An easy way to accomplish the library switching is to use dev_mode() without arguments (from the devtools package). After the first dev_mode() command is issued the default library becomes ~/R-dev . At that point install the new version of asrmel using an ordinary install.packages command without specifying lib= and it will be installed into ~/R-dev. Loading it using library without specifying a library will cause it to look into ~/R-dev first. Then test it out and finally when you are ready to switch back to the original library and original asreml issue dev_mode() again. dev_mode() manipulates the default library paths so you can use .libPaths() without arguments at any time to check what the current default is.

library(devtools)
dev_mode() # ~/R-dev now default library
# ...
dev_mode() # restore usual default library

3) changer The changer package can be used to change the name of a package making all the changes needed to the source. Use it to change the name of one of the versions and then both can be loaded. See Use function from a package but different versions simultaneously for more discussion of changer.

G. Grothendieck
  • 254,981
  • 17
  • 203
  • 341
  • Editing the DESCRIPTION file was enough for my use case. Thanks for the detailed response. – BioGeek Oct 01 '18 at 08:25
  • Could you elaborate a bit where and how you have to edit the DESCRIPTION file? I tried this for a different fork of the openxlsx package, but withouth success so far, see this questions. https://stackoverflow.com/questions/56168063/using-two-versions-of-openxlsx-forks-in-same-file – Max M May 16 '19 at 17:05