RStudio 和命令行 R 之间的 R .libPaths() 区别 [英] R .libPaths() difference between RStudio and command-line R

查看:49
本文介绍了RStudio 和命令行 R 之间的 R .libPaths() 区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我从命令行运行 R 时:

When I run R from the command line:

> library(ggplot2)
...
> path.package('ggplot2')
[1] "/home/yang/R/x86_64-pc-linux-gnu-library/2.13/ggplot2"
> .libPaths()
[1] "/home/yang/R/x86_64-pc-linux-gnu-library/2.13"
[2] "/usr/local/lib/R/site-library"                
[3] "/usr/lib/R/site-library"                      
[4] "/usr/lib/R/library"                           
> Sys.getenv('R_LIBS_USER')
[1] "~/R/x86_64-pc-linux-gnu-library/2.13"

(注意:当我从 shell 中检查时,该环境变量实际上并不存在.)

(Note: that environment variable actually doesn't exist when I check from my shell.)

但是从运行在同一台机器上的 RStudio Server,并在以同一用户身份登录后:

But from RStudio Server running on the same box, and after logging in as the same user:

> path.package('ggplot2')
[1] "/home/yang/R/library/ggplot2"
> .libPaths()
[1] "/home/yang/R/library"              "/usr/local/lib/R/site-library"    
[3] "/usr/lib/R/site-library"           "/usr/lib/R/library"               
[5] "/usr/lib/rstudio-server/R/library"
> Sys.getenv('R_LIBS_USER')
[1] "/home/yang/R/library"

你能解释为什么默认情况下这些是不同的吗?这是 RStudio 定制吗?(为什么?)提前致谢.

Can you explain why these are different by default? Is this an RStudio customization? (Why?) Thanks in advance.

推荐答案

一个快速的谷歌搜索让我在这里:

A quick googling got me here:

http://support.rstudio.org/help/discussions/problems/868-how-to-configure-libpaths

所以看起来 RStudio 使用自己的库,设置在/etc/rstudio/rsession.conf 中.为什么?谁知道呢.

so it looks like RStudio uses its own libs, set in /etc/rstudio/rsession.conf. Why? Who knows.

这篇关于RStudio 和命令行 R 之间的 R .libPaths() 区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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