如何从windows上的源tarball安装一个R包?

时间:2023-01-12 19:52:53

The forecast package for R has been updated to version 2.12, but there are currently only windows binarys for 2.11 available on CRAN.

R的预测包已经更新到2.12版本,但是目前CRAN上只有windows binarys的2.11版本。

How do I install an R package from the source on Windows?

如何从Windows上的源代码安装R包?

5 个解决方案

#1


44  

I know this is an old question but it came up first in my Google search for this same question, even though I knew the answer I just wanted something to copy and paste. Which makes it worth improving the answer for future reference. So here is what works for me:

我知道这是个老问题,但在谷歌搜索这个问题时,它首先出现,尽管我知道答案,我只是想复制粘贴。这使我们有必要改进答案,以供将来参考。这就是我的工作:

Install rtools, then:

安装rtools,然后:

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

#2


7  

Start by reviewing the section on Windows packages in the R Installation and Administration manual, then carefully follow the instructions from The Windows toolset appendix.

首先在安装和管理手册中检查Windows软件包,然后仔细遵循Windows工具集附录中的说明。

I know it's usually bad form to mainly provide links in an answer, but these are links to the canonical references on this topic. I simply link to them rather than summarize their contents, since they should be accurate for the most current R release.

我知道在回答中主要提供链接通常是不好的形式,但是这些链接指向有关这个主题的规范引用。我只是链接到它们,而不是总结它们的内容,因为它们对于当前的R版本应该是准确的。

#3


4  

Two answers that may help you avoid the hassle of installing Rtools.

这两个答案可以帮助您避免安装Rtools的麻烦。

  1. Use http://win-builder.r-project.org/ to build a binary version, download it, and install (using install.packages(...,repos=NULL))
  2. 使用http://win-builder.r-project.org/构建二进制版本,下载并安装(使用install.packages(…,repos=NULL))
  3. If the package has no binary component (i.e. no src directory with C, C++, or Fortran code that needs to be compiled during installation (not true for forecast, but possibly useful some other time) then simply specifying type="source" within the install.packages call (whether from a repository or a local copy of the source tarball (.tar.gz file)) will install the source package, even on Windows.
  4. 如果该包没有二进制组件(即没有包含C、c++或需要在安装期间编译的Fortran代码的src目录(对于forecast来说不是这样,但在其他时候可能有用),那么只需在安装中指定type="source"即可。包调用(无论是来自存储库还是源tarball的本地副本(.tar)。)将安装源包,即使是在Windows上。

#4


3  

  1. Download the package *.tar.gz.
  2. * gz下载包。
  3. make sure you have Rtools installed.
  4. 确保安装了Rtools。
  5. Make sure the R and Rtools paths are added in the environment varialble.
  6. 确保在不同的环境中添加R和Rtools路径。
  7. Open a command prompt. Type R CMD INSTALL packagename.tar.gz.
  8. 打开一个命令提示符。类型R CMD安装packagename.tar.gz。

it will work i hope.

我希望这行得通。

#5


2  

I'm not sure if this is the best way, but I found the following method to work (based in part on the answers above):

我不确定这是不是最好的方法,但是我找到了下面的方法来工作(部分基于上面的回答):

1) Download the package .tar

1)下载软件包。tar

2) Move the package to the directory with your user R libraries (e.g., in my case it was "C:/Users/yourUserName/Documents/R/win-library/3.3")

2)使用用户R库将包移动到目录(例如,在我的例子中,它是“C:/Users/yourUserName/Documents/R/win-library/3.3”)

3) Within Rstudio (or elsewhere, probably), run the command... install.packages("packageName.tar", repos=NULL, type="source")

3)在Rstudio(或者其他地方)中运行命令……install.packages(“packageName。焦油”,回购= NULL,type = "源”)

That worked for me at least. Hope it's helpful!

至少对我来说是这样。希望它是有帮助的!

#1


44  

I know this is an old question but it came up first in my Google search for this same question, even though I knew the answer I just wanted something to copy and paste. Which makes it worth improving the answer for future reference. So here is what works for me:

我知道这是个老问题,但在谷歌搜索这个问题时,它首先出现,尽管我知道答案,我只是想复制粘贴。这使我们有必要改进答案,以供将来参考。这就是我的工作:

Install rtools, then:

安装rtools,然后:

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

#2


7  

Start by reviewing the section on Windows packages in the R Installation and Administration manual, then carefully follow the instructions from The Windows toolset appendix.

首先在安装和管理手册中检查Windows软件包,然后仔细遵循Windows工具集附录中的说明。

I know it's usually bad form to mainly provide links in an answer, but these are links to the canonical references on this topic. I simply link to them rather than summarize their contents, since they should be accurate for the most current R release.

我知道在回答中主要提供链接通常是不好的形式,但是这些链接指向有关这个主题的规范引用。我只是链接到它们,而不是总结它们的内容,因为它们对于当前的R版本应该是准确的。

#3


4  

Two answers that may help you avoid the hassle of installing Rtools.

这两个答案可以帮助您避免安装Rtools的麻烦。

  1. Use http://win-builder.r-project.org/ to build a binary version, download it, and install (using install.packages(...,repos=NULL))
  2. 使用http://win-builder.r-project.org/构建二进制版本,下载并安装(使用install.packages(…,repos=NULL))
  3. If the package has no binary component (i.e. no src directory with C, C++, or Fortran code that needs to be compiled during installation (not true for forecast, but possibly useful some other time) then simply specifying type="source" within the install.packages call (whether from a repository or a local copy of the source tarball (.tar.gz file)) will install the source package, even on Windows.
  4. 如果该包没有二进制组件(即没有包含C、c++或需要在安装期间编译的Fortran代码的src目录(对于forecast来说不是这样,但在其他时候可能有用),那么只需在安装中指定type="source"即可。包调用(无论是来自存储库还是源tarball的本地副本(.tar)。)将安装源包,即使是在Windows上。

#4


3  

  1. Download the package *.tar.gz.
  2. * gz下载包。
  3. make sure you have Rtools installed.
  4. 确保安装了Rtools。
  5. Make sure the R and Rtools paths are added in the environment varialble.
  6. 确保在不同的环境中添加R和Rtools路径。
  7. Open a command prompt. Type R CMD INSTALL packagename.tar.gz.
  8. 打开一个命令提示符。类型R CMD安装packagename.tar.gz。

it will work i hope.

我希望这行得通。

#5


2  

I'm not sure if this is the best way, but I found the following method to work (based in part on the answers above):

我不确定这是不是最好的方法,但是我找到了下面的方法来工作(部分基于上面的回答):

1) Download the package .tar

1)下载软件包。tar

2) Move the package to the directory with your user R libraries (e.g., in my case it was "C:/Users/yourUserName/Documents/R/win-library/3.3")

2)使用用户R库将包移动到目录(例如,在我的例子中,它是“C:/Users/yourUserName/Documents/R/win-library/3.3”)

3) Within Rstudio (or elsewhere, probably), run the command... install.packages("packageName.tar", repos=NULL, type="source")

3)在Rstudio(或者其他地方)中运行命令……install.packages(“packageName。焦油”,回购= NULL,type = "源”)

That worked for me at least. Hope it's helpful!

至少对我来说是这样。希望它是有帮助的!