[英]Changeing directory in R studio when installing packages
How do i choose the library which the package is install in in Rstudio?如何选择 package 安装在 Rstudio 中的库?
When i run "install and restart" i get this error:当我运行“安装并重新启动”时,出现此错误:
installing to library 'C:/Program Files/R/R-4.0.0/library'
Error: ERROR: no permission to install to directory 'C:/Program Files/R/R-4.0.0/library'
Exited with status 1.
I want it to install on "h:/r_packages"我希望它安装在“h:/r_packages”上
As I understand you want to install your personal package.据我了解,您想安装您的个人 package。 I don't find any option for the library path in RStudio.
我在 RStudio 中找不到库路径的任何选项。 You can run this code in the console:
您可以在控制台中运行此代码:
withr::with_libpaths("h:/r_packages", devtools::install())
You have to run this command when the current directory is the one of the package.当当前目录是 package 之一时,您必须运行此命令。 Otherwise use the
pkg
argument of devtools::install
to specify the package directory.否则使用
devtools::install
的pkg
参数指定 package 目录。
The second argument of install.packages
is lib
, which specifies the library directory. install.packages
的第二个参数是lib
,它指定库目录。 The help reads:帮助内容如下:
lib
character vector giving the library directories
where to install the packages.
Recycled as needed.
If missing, defaults to the first element of .libPaths().
So, the below would work, though I cannot try on my end.因此,尽管我无法尝试,但下面的方法会起作用。
install.packages("package_name", lib="h:/r_packages")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.