rstudio 命令行 R 的不同库路径(`$R_LIBS_USER`) [英] rstudio different library path to command-line R (`$R_LIBS_USER`)

查看:96
本文介绍了rstudio 命令行 R 的不同库路径(`$R_LIBS_USER`)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试找出为什么我的 .libPath 在命令行 R 和 RStudio Desktop 之间不同(注意:这不是> 这个问题的副本,因为该修复涉及特定于 RStudio Server 的东西,我没有).

当我在命令行 (linux) 上使用 R 时:

<代码>>.libPaths()[1] "/home/mathematicalcoffee/R/library" "/usr/local/lib/R/site-library"[3] "/usr/lib/R/site-library" "/usr/lib/R/library"

当我使用 RStudio 桌面(Linux,同一台机器)时:

[1] "/usr/local/lib/R/site-library" "/usr/lib/R/site-library" "/usr/lib/R/library" "/usr/lib/rstudio/R/图书馆"

现在我已在我的 bash 配置文件中将 $R_LIBS_USER 设置为 ~/R/library,因此 R 命令行将其选为我首选的 libPath.

当我这样做时,问题出在 RStudio 桌面上:

Sys.getenv('R_LIBS_USER')# "~/R/x86_64-pc-linux-gnu-library/2.15"

那么为什么 RStudio Desktop 更改了我的 R_LIBS_USER?我怎样才能把它改回来?(我不使用 .Rprofile 文件).(在我上面链接的问题中,RStudio Server 的解决方案是修改 /etc/rstudio/rsession.conf,但我没有,因为我有 RStudio 桌面.另外,我相信RStudio 应该尊重我的 R_LIBS_USER 环境变量.)

解决方案

你写的:

<块引用>

现在我已经在我的 bash 配置文件中将 $R_LIBS_USER 设置为 ~/R/library,

您是否偶然从 gui 图标调用 RStudio,即没有调用您的 ~/.bash_profile ?也许你可以尝试调用一个包装器来代替它?

就其价值而言,.libPaths() 在 RStudio 桌面和服务器(尽管服务器附加其内部目录)下返回相同的内容,R 在命令行上并通过 ESS 为我返回.

一般来说,阅读 help(Startup) 会很划算.@flodel 的评论非常恰当.如果您在系统级别始终无法处理这个问题,您可以随时转向 R,无论是在其系统级别(通过 RenvironRenviron.site)还是通过~/R/ 目录.

I'm trying to work out why my .libPath is different between command-line R and RStudio Desktop (NOTE: this is not a duplicate of this question as that fix involved stuff specific to RStudio Server which I don't have).

When I use R on the command-line (linux):

> .libPaths()
[1] "/home/mathematicalcoffee/R/library"  "/usr/local/lib/R/site-library"
[3] "/usr/lib/R/site-library"             "/usr/lib/R/library"           

When I use RStudio Desktop (linux, same machine):

[1] "/usr/local/lib/R/site-library" "/usr/lib/R/site-library"       "/usr/lib/R/library"            "/usr/lib/rstudio/R/library"  

Now I have set $R_LIBS_USER to ~/R/library in my bash profile, so R-command-line picks it up as my preferred libPath.

The problem is in RStudio Desktop when I do:

Sys.getenv('R_LIBS_USER')
# "~/R/x86_64-pc-linux-gnu-library/2.15"

So why has RStudio Desktop changed my R_LIBS_USER? How can I change it back? (I don't use an .Rprofile file). (In the question I linked above the solution for RStudio Server was to modify /etc/rstudio/rsession.conf, but I don't have that as I've got RStudio Desktop. Also, I believe RStudio should be respecting my R_LIBS_USER environment variable.)

解决方案

You write:

Now I have set $R_LIBS_USER to ~/R/library in my bash profile,

Do you by chance call RStudio from a gui icon, ie without invoking your ~/.bash_profile ? Maybe you can try calling a wrapper instead which sets it?

For what it is worth, .libPaths() returns the same thing under RStudio Desktop and Server (though Server appends its internal directory), R on the command-line and via ESS for me.

Edit: And in general, do read help(Startup) which will be time well-spent. The comment by @flodel is quite appropriate. If you get lost dealing with this consistently at the system level, you can always turn to R, either at its system-level (via Renviron and Renviron.site) or via the ~/R/ directory.

这篇关于rstudio 命令行 R 的不同库路径(`$R_LIBS_USER`)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆