Install binary zipped R package via command line

前端 未结 3 2053
青春惊慌失措
青春惊慌失措 2021-02-04 00:36

I am trying to install zipped binary R packages via command line on a windows 7 machine with

R CMD INSTALL packagename

but it doesn\'t work. I

3条回答
  •  轮回少年
    2021-02-04 01:18

    You can use the Rscript front end to run code as if it were in a running R session. Say the package you want to install is foo.zip in the current working directory. I'm probably abusing Rscript here, but it works for me:

    Rscript -e "install.packages('foo.zip', repos = NULL)"
    

    You need to supply the path to the binary package if it is not in the directory where there script is running. repos = NULL is the trick to get install.packages() to work from a local file. Read ?install.packages for more info on other arguments you might want to specify, especially lib. Note that you don't benefit from automatic dependency resolution when doing this - you need a repo for that and if you supply one, R will try to download packages.

    You are right about R CMD INSTALL; the R Installation and Administration manual has the following in Section 6.3:

    To install packages from source in a Unix-alike use

        R CMD INSTALL -l /path/to/library pkg1 pkg2 ...
    

提交回复
热议问题