我需要使用我的用户定义的文件夹来存储我的包。我引用了下面给出的链接。
我也用了同样的方法,但对我不起作用。我已经创建了一个名为.Renviron的文件,其中包含数据R_LIBS=c:/R包,其中安装了我的包。但是,它仍然表明不存在这样的包'RODBC‘。此外,我把这个文件放在我的C驱动器的Documents文件夹中,并尝试了。这也给出了同样的错误。文件类型仍然显示为文本文档。如何更改此文件类型?
发布于 2019-05-14 16:14:40
在mac (或linux)上
打开终端并键入
touch $HOME/.Renviron要打开刚刚创建的文件,请通过finder导航到/Users/<your-user-name>/.Renviron,或者只需打开终端并输入
open $HOME/.Renviron在windows上
单击start并打开powershell。将此代码复制到powershell中
Add-Content c:\Users\$env:USERNAME\Documents\.Renviron "TEST_VARIABLE_1=my_username"
Add-Content c:\Users\$env:USERNAME\Documents\.Renviron "TEST_VARIABLE_2=123"现在,在Documents文件夹中将有一个名为.Renviron的文件。关闭并重新打开RStudio。然后运行Sys.getenv('TEST_VARIABLE_1')来访问R中的变量(显然,这也适用于您设置的任何其他环境变量)。
发布于 2016-11-24 22:18:32
看看help(Startup),它的末尾有一个例子:
## Example ~/.Renviron on Unix
R_LIBS=~/R/library
PAGER=/usr/local/bin/less
## Example .Renviron on Windows
R_LIBS=C:/R/library
MY_TCLTK="c:/Program Files/Tcl/bin"
## Example of setting R_DEFAULT_PACKAGES (from R CMD check)
R_DEFAULT_PACKAGES='utils,grDevices,graphics,stats'
# this loads the packages in the order given, so they appear on
# the search path in reverse order.但请注意拼写: e小写的Renviron。只需使用文本编辑器编辑文件即可。还要注意,R在其RHOME下的一个系统文件夹etc/中有一个变体
edd@bud:~$ R RHOME
/usr/lib/R
edd@bud:~$ cat $(R RHOME)/etc/Renviron.site
## Emacs please make this -*- R -*-
## empty Renviron.site for R on Debian
##
## Copyright (C) 2008 Dirk Eddelbuettel and GPL'ed
##
## see help(Startup) for documentation on ~/.Renviron and Renviron.site
# ## Example ~/.Renviron on Unix
# R_LIBS=~/R/library
# PAGER=/usr/local/bin/less
# ## Example .Renviron on Windows
# R_LIBS=C:/R/library
# MY_TCLTK="c:/Program Files/Tcl/bin"
# ## Example of setting R_DEFAULT_PACKAGES (from R CMD check)
# R_DEFAULT_PACKAGES='utils,grDevices,graphics,stats'
# # this loads the packages in the order given, so they appear on
# # the search path in reverse order.
edd@bud:~$ 嗯。看起来我是为Debian包写的,它确实一直存在。您仍然可以复制它。
发布于 2020-02-25 19:50:36
可能值得补充的是,package 现在提供了一系列功能,便于轻松编辑和打开R启动文件。edit_*系列函数可用于方便地编辑所需的启动和配置文件。要编辑存储相关配置的适当位置的.Renviron,请使用:
# Edit Renviron
usethis::edit_r_environ()
# You can also consider creating project-specific settings:
usethis::edit_r_environ(scope = "project")for这提供了其他对管理R配置有用的功能。例如,要编辑Makevars,您可以执行以下操作:
# Edit .R/Makevars
usethis::edit_r_makevars()https://stackoverflow.com/questions/40788645
复制相似问题