How do I install an R package from source?

后端 未结 6 706
半阙折子戏
半阙折子戏 2020-11-22 01:46

A friend sent me along this great tutorial on webscraping NYtimes with R. I would really love to try it. However, the first step is to installed a package called RJSONIO fro

6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-22 02:28

    A supplementarily handy (but trivial) tip for installing older version of packages from source.

    First, if you call "install.packages", it always installs the latest package from repo. If you want to install the older version of packages, say for compatibility, you can call install.packages("url_to_source", repo=NULL, type="source"). For example:

    install.packages("http://cran.r-project.org/src/contrib/Archive/RNetLogo/RNetLogo_0.9-6.tar.gz", repo=NULL, type="source")
    

    Without manually downloading packages to the local disk and switching to the command line or installing from local disk, I found it is very convenient and simplify the call (one-step).

    Plus: you can use this trick with devtools library's dev_mode, in order to manage different versions of packages:

    Reference: doc devtools

提交回复
热议问题