How do you use multiple versions of the same R package?

后端 未结 2 1872
失恋的感觉
失恋的感觉 2020-11-29 22:04

In order to be able to compare two versions of a package, I need to able to choose which version of the package that I load. R\'s package system is set to by default to ove

2条回答
  •  伪装坚强ぢ
    2020-11-29 22:26

    You could selectively alter the library path. For complete transparency, keep both out of your usual path and then do

     library(foo, lib.loc="~/dev/foo/v1")    ## loads v1
    

    and

     library(foo, lib.loc="~/dev/foo/v2")    ## loads v2
    

    The same works for install.packages(), of course. All these commands have a number of arguments, so the hooks you aim for may already be present. So don't look at changing R_HOME, rather look at help(install.packages) (assuming you install from source).

    But AFAIK you cannot load the same package twice under the same name.

提交回复
热议问题