如何重新安装base-R包(例如,stats、graphics、utils等)?

时间:2022-09-15 06:09:25

I have been using the "stats" package in R 3.0.1 without any problems . But today i deleted the "stats" folder from the R library location and now I can't install it any more. I tried doing the same thing with other packages but I could install everything except "stats"

我已经使用了R 3.0.1中的“stats”包,没有任何问题。但是今天我从R库的位置删除了“stats”文件夹,现在我不能再安装它了。我试着用其他的包做同样的事情但是我可以安装除了“stats”之外的所有东西

install.packages("stats", dep = TRUE, repos="http://cran.cs.wwu.edu")

## Installing package into ‘%Default R Lib Installation Path%’   
## (as ‘lib’ is unspecified)  
## Warning in install.packages :   package ‘stats’ is not available (for R version 3.0.1)

I also tried downloading it from other sources like "http://cran.ma.imperial.ac.uk/" but nothing works . Any ideas?

我还试着从其他来源下载它,比如“http://cran.ma.imperial.ac。”英国/“但什么都不奏效。”什么好主意吗?

2 个解决方案

#1


9  

(Since SO is nagging me not to continue the comment thread, I will post an answer.)

(既然如此,唠叨我不要继续评论帖子,我会发布一个答案。)

I believe that this problem will apply to any base package (but not to those installed from repositories, and probably not to Recommended packages): I am deeply skeptical that stats is the only package. It should occur for any of the packages in this list:

我相信这个问题将适用于任何基本包(但不适用于那些从存储库中安装的包,并且可能不推荐使用包):我非常怀疑统计是唯一的包。它应该出现在这个列表中的任何一个包中:

rownames(subset(as.data.frame(installed.packages()),Priority=="base"))

I'm sure it's theoretically possible to re-install a base package from scratch, but it will be much easier to re-install R. At a guess, it would take me about 15 minutes to re-install R, and I would feel lucky if I figured out how to re-install a base package on its own in less than an hour.

我相信它从头开始重新安装基础方案在理论上是可能的,但这将是更容易安装R .猜,需要大概15分钟重新安装R,我会感到幸运,如果我知道如何重新安装包在自己的基地在不到一个小时。

I'm pretty sure that re-installing R will not affect previously-installed packages: see e.g. http://cran.r-project.org/bin/windows/base/rw-FAQ.html#How-do-I-UNinstall-R_003f; that link is about uninstalling rather than re-installing, but this seems relevant:

我很确定重新安装R不会影响之前安装的软件包:参见http://cran.r project.org/bin/windows/base/rw- faq.html # how-do - uninstall-r_003f;这个链接是关于卸载而不是重新安装,但这似乎是相关的:

Uninstalling R only removes files from the initial installation, not (for example) packages you have installed or updated.

卸载R只从初始安装中删除文件,而不是安装或更新的包(例如)。

Other choices would be

其他的选择是

  • create another identical installation of R (on another machine, or in a non-default location); locate the relevant directories in your new installation and copy them over to your existing installation.
  • 创建另一个相同的R(在另一台机器上,或在非默认位置)安装;在新安装中找到相关目录并将其复制到现有的安装中。
  • restore the relevant directories from your backup.
  • 从备份中恢复相关目录。

PS: obviously if you are doing this on a client's machine it would be a good idea to test my advice first ...

PS:显然,如果你是在客户的机器上做这件事,最好先测试一下我的建议……

#2


0  

What worked for me was to copy the entire package folder from another to my R.home() directory.

对我有用的是将整个包文件夹从另一个文件夹复制到我的R.home()目录。

#1


9  

(Since SO is nagging me not to continue the comment thread, I will post an answer.)

(既然如此,唠叨我不要继续评论帖子,我会发布一个答案。)

I believe that this problem will apply to any base package (but not to those installed from repositories, and probably not to Recommended packages): I am deeply skeptical that stats is the only package. It should occur for any of the packages in this list:

我相信这个问题将适用于任何基本包(但不适用于那些从存储库中安装的包,并且可能不推荐使用包):我非常怀疑统计是唯一的包。它应该出现在这个列表中的任何一个包中:

rownames(subset(as.data.frame(installed.packages()),Priority=="base"))

I'm sure it's theoretically possible to re-install a base package from scratch, but it will be much easier to re-install R. At a guess, it would take me about 15 minutes to re-install R, and I would feel lucky if I figured out how to re-install a base package on its own in less than an hour.

我相信它从头开始重新安装基础方案在理论上是可能的,但这将是更容易安装R .猜,需要大概15分钟重新安装R,我会感到幸运,如果我知道如何重新安装包在自己的基地在不到一个小时。

I'm pretty sure that re-installing R will not affect previously-installed packages: see e.g. http://cran.r-project.org/bin/windows/base/rw-FAQ.html#How-do-I-UNinstall-R_003f; that link is about uninstalling rather than re-installing, but this seems relevant:

我很确定重新安装R不会影响之前安装的软件包:参见http://cran.r project.org/bin/windows/base/rw- faq.html # how-do - uninstall-r_003f;这个链接是关于卸载而不是重新安装,但这似乎是相关的:

Uninstalling R only removes files from the initial installation, not (for example) packages you have installed or updated.

卸载R只从初始安装中删除文件,而不是安装或更新的包(例如)。

Other choices would be

其他的选择是

  • create another identical installation of R (on another machine, or in a non-default location); locate the relevant directories in your new installation and copy them over to your existing installation.
  • 创建另一个相同的R(在另一台机器上,或在非默认位置)安装;在新安装中找到相关目录并将其复制到现有的安装中。
  • restore the relevant directories from your backup.
  • 从备份中恢复相关目录。

PS: obviously if you are doing this on a client's machine it would be a good idea to test my advice first ...

PS:显然,如果你是在客户的机器上做这件事,最好先测试一下我的建议……

#2


0  

What worked for me was to copy the entire package folder from another to my R.home() directory.

对我有用的是将整个包文件夹从另一个文件夹复制到我的R.home()目录。