安装和使用软件包时,我在 RStudio 中遇到问题。我对它非常陌生,所以在我描述它时请耐心等待:
这是我的 PC 中的新 R 和 Rstudio 安装,R 版本 4.1.2。由于生活问题而进行的远程工作。我通常在我的工作计算机上毫无问题地运行这些相同的命令(总是在管理员模式下)。
但是,在安装“readxl”以打开 excel 文件时:
> install.packages("readxl")
Installing package into ‘C:/Program Files/R/R-4.1.2’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.1/readxl_1.3.1.zip'
Content type 'application/zip' length 1717234 bytes (1.6 MB)
downloaded 1.6 MB
package ‘readxl’ successfully unpacked and MD5 sums checked
Warning in install.packages :
cannot remove prior installation of package ‘readxl’
Warning in install.packages :
problem copying C:\Program Files\R\R-4.1.2\00LOCK\readxl\libs\x64\readxl.dll to C:\Program Files\R\R-4.1.2\readxl\libs\x64\readxl.dll: Permission denied
Warning in install.packages :
restored ‘readxl’
The downloaded binary packages are in
C:\Users\Andrés RM\AppData\Local\Temp\Rtmp2RhFPr\downloaded_packages
我已阅读有关删除00lock
以避免此问题的信息,但我无法在任何地方找到该文件。
当我使用 libpath() 检查我的库时
> .libPaths()
[1] "C:/Program Files/R/R-4.1.2" "C:/Program Files/R/R-4.1.2/library"
然后,如果我想加载库
> library(readxl)
Warning message:
In normalizePath(path.expand(path), winslash, mustWork) :
path[1]="C:/Users/my_user/Documents": The system cannot find the path specified
它返回一个我从未指定过的路径,并且我没有保留任何其他 R 库。
如果我尝试加载一个 excel 文件:
R_meristem_measures <- read_excel("C:/Users/my_user/Desktop/R meristem measures.xlsx")
Error: Evaluation error: zip file 'C:\Users\my_user\Desktop\R meristem measures.xlsx' cannot be opened.
In addition: Warning message:
In normalizePath(path.expand(path), winslash, mustWork) :
path[1]="C:/Users/Andrés RM/Desktop/R meristem measures.xlsx": The system cannot find the path specified
在此之后,.libPaths()
不断返回相同的结果。
我每天使用的其他一些软件包(在我的另一台计算机上)会发生这种情况,并且警告是相同的。
但是,我只是尝试在本机 R (R x64 4.1.2) 中运行相同的代码,它运行完美,没有任何问题。
我在这里不知所措。其中,我尝试过sys.setenv(R_LIBS_USER)
并且还从控制面板更改了相同的环境变量。R_LIBS="C:/R/library"
也不起作用。
在工作中我使用 R 4.0 并libPaths()
返回
.libPaths()
[1] "C:/Users/my_user/Documents/R/win-library/4.0" "C:/Program Files/R/R-4.0.2/library"
这是预期的,因为 my_user/etc 是我保存包裹的地方。
这是我的计算机的问题还是 RStudio 的某些特定问题?R 本身运行良好,但使用起来很痛苦,即使我可以在 R 控制台中运行我的东西,我也想使用 RStudio。
谢谢大家