How do I install an R package from source?

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 from source.

I know R reasonably well, but I have no idea how to install a package from source.

I'm running Mac OSX.


If you have the file locally, then use install.packages() and set the repos=NULL :

install.packages(path_to_file, repos = NULL, type="source")

Where path_to_file would represent the full path and file name:

  • On Windows it will look something like this: "C:RJSONIO_0.2-3.tar.gz" .
  • On UNIX it will look like this: "/home/blah/RJSONIO_0.2-3.tar.gz" .

  • Download the source package, open Terminal.app, navigate to the directory where you currently have the file, and then execute:

    R CMD INSTALL RJSONIO_0.2-3.tar.gz
    

    Do note that this will only succeed when either: a) the package does not need compilation or b) the needed system tools for compilation are present. See: https://cran.r-project.org/bin/macosx/tools/


    您可以直接从存储库安装(请注意type="source" ):

    install.packages("RJSONIO", repos = "http://www.omegahat.org/R", type="source")
    
    链接地址: http://www.djcxy.com/p/25014.html

    上一篇: 如何在Eclipse Package Explorer中查看分层结构的包结构

    下一篇: 我如何从源代码安装R包?