本文介绍了安装 R 包时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮帮我,我无法安装MASS"包.

Please help me, I cannot install "MASS" package.

> library(MASS)
Error in library(MASS) : there is no package called ‘MASS’

我尝试从本地安装 MASS 包:

I tried to install MASS package from local:

> utils:::menuInstallLocal()
package ‘MASS’ successfully unpacked and MD5 sums checked
Warning: cannot remove prior installation of package ‘MASS’

即使我也无法删除MASS":

Even I cannot remove "MASS":

> remove.packages("MASS")
Removing package from ‘C:/Program Files/R/R-3.0.1/library’
(as ‘lib’ is unspecified)
Error in find.package(pkgs, lib) : there is no package called ‘MASS’

同样使用此选项我无法安装软件包:

Also with this option I couldn't install package:

> options(install.lock=T)
> utils:::menuInstallLocal()
package ‘MASS’ successfully unpacked and MD5 sums checked
Warning: cannot remove prior installation of package ‘MASS’
Warning: restored ‘MASS’
Warning message:
In file.copy(savedcopy, lib, recursive = TRUE) :
  problem copying C:Program FilesRR-3.0.1library0LOCKMASSlibsx64MASS.dll to C:Program FilesRR-3.0.1libraryMASSlibsx64MASS.dll: Permission

还有 install.packages:

And with install.packages:

> install.packages("C:\MASS_7.3-35.zip",repos=NULL)
package ‘MASS’ successfully unpacked and MD5 sums checked
Warning: cannot remove prior installation of package ‘MASS’
Warning: restored ‘MASS’
Warning message:
In file.copy(savedcopy, lib, recursive = TRUE) :
  problem copying C:Program FilesRR-3.0.1library0LOCKMASSlibsx64MASS.dll to C:Program FilesRR-3.0.1libraryMASSlibsx64MASS.dll: Permission

我应该提到我将 R 与 ORE (Oracle R Enterprise) 结合使用.

I should mention I use R with ORE (Oracle R Enterprise).

推荐答案

这里可能会发生一些事情.首先确定您的图书馆位置:

There could be a few things happening here. Start by first figuring out your library location:

Sys.getenv("R_LIBS_USER")

.libPaths()

我们已经从您提供的信息中知道您的:C:Program FilesRR-3.0.1library

We already know yours from the info you gave: C:Program FilesRR-3.0.1library

我相信您在那里有一个名为:00LOCK 的文件.来自 ?install.packages:

I believe you have a file in there called: 00LOCK. From ?install.packages:

请注意,包安装可能会严重失败以致于没有删除锁定目录:这将禁止进一步安装到库目录(或对于包的 --pkglock),直到删除锁定目录手动.

您需要删除该文件.如果您安装了 pacman 包,您可以简单地使用 p_unlock() 并删除 00LOCK 文件.在删除 00LOCK 文件之前,您现在无法安装 pacman.

You need to delete that file. If you had the pacman package installed you could have simply used p_unlock() and the 00LOCK file is removed. You can't install pacman now until the 00LOCK file is removed.

要安装 pacman 使用:

install.packages("pacman")

可能还有第二个问题.这就是您以某种方式破坏 MASS 的地方.根据我的经验,如果您尝试更新正在另一个 R 会话中使用的包,就会发生这种情况.我相信还有其他方法会导致这种情况.要解决此问题,请尝试:

There may be a second issue. This is where you somehow corrupted MASS. This can occur, in my experience, if you try to update a package while it is in use in another R session. I'm sure there's other ways to cause this as well. To solve this problem try:

  1. 关闭所有 R 会话(使用任务管理器确保您真正没有 R 会话) + +
  2. 转到您的图书馆位置Sys.getenv("R_LIBS_USER").在您的情况下,这是:C:Program FilesRR-3.0.1library
  3. 手动删除MASS
  4. 启动 R 的原版会话
  5. 通过install.packages("MASS")
  6. 安装MASS
  1. Close out of all R sessions (use task manager to ensure you're truly R session free) + +
  2. Go to your library location Sys.getenv("R_LIBS_USER"). In your case this is: C:Program FilesRR-3.0.1library
  3. Manually delete the MASS package
  4. Fire up a vanilla session of R
  5. Install MASS via install.packages("MASS")

如果其中任何一项有效,请告诉我什么有效.

If any of this works please let me know what worked.

这篇关于安装 R 包时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-10 20:17