【问题标题】:How to set R environment in /etc/profile?如何在 /etc/profile 中设置 R 环境?
【发布时间】:2012-07-29 01:30:38
【问题描述】:

我的操作系统是debian6,我编译安装R后有一个libR.pc

root@debian:/home/tiger# cat /home/tiger/R-2.15.1/lib/pkgconfig/libR.pc  
rhome=/home/tiger/R-2.15.1/lib/R  
rlibdir=${rhome}/lib  
rincludedir=/home/tiger/R-2.15.1/lib/R/include  
Name: libR  
Description: R as a library  
Version: 2.15.1  
Libs: -L${rlibdir} -lR  
Cflags: -I${rincludedir} -I${rincludedir}  
Libs.private:  

在 /etc/profile 中设置 R 环境时:
R_HOME= /home/tiger/R-2.15.1

R_HOME= /home/tiger/R-2.15.1/lib/R
我会选择在 /etc/profile 中写入哪一行?

【问题讨论】:

标签: r environment


【解决方案1】:

在 Debian(或衍生产品,例如 Ubuntu 系统)上,您有 /etc/R/ 来设置 R 使用的变量:

edd@max:~$ ls -l /etc/R/
total 28
-rw-r--r-- 1 root root  602 Jun 17 20:29 ldpaths
-rw-r--r-- 1 root root 5461 Jun 17 20:29 Makeconf
-rw-r--r-- 1 root root 1868 Mar 31 13:50 Renviron
-rw-r--r-- 1 root root  608 Sep 25  2009 Renviron.site
-rw-r--r-- 1 root root 1159 Mar 31 08:03 repositories
-rw-r--r-- 1 root root  792 Oct 28  2009 Rprofile.site
edd@max:~$ 

R_HOME/etc/ 中的文件应该是软链接 --- 至少如果您使用预构建的二进制文件。如果您构建自己的二进制文件,那是您的问题。

您引用的文件在 Debian / Ubuntu 系统上安装为 /usr/lib/pkgconfig/libR.pc不需要设置R_HOME,因为R 会找到自己的值(请参阅@flodel 的答案)。

【讨论】:

    【解决方案2】:

    在我的系统上:

    cat $R_HOME
    

    什么都不提供,但在 R 会话中,我得到:

    > Sys.getenv("R_HOME")
    [1] "/usr/lib/R"
    

    这应该告诉你两件事:

    1. R_HOME 是在 R 的启动时设置的,所以除非您确切知道自己在做什么,否则您可能不需要在您的 /etc/profile 中设置它。
    2. 您可以使用Sys.getenv 找出您的R_HOME 的确切路径。

    【讨论】:

      猜你喜欢
      • 2016-07-17
      • 2017-06-24
      • 1970-01-01
      • 2014-01-01
      • 1970-01-01
      • 2014-04-25
      • 2019-12-24
      • 1970-01-01
      • 2023-02-18
      相关资源
      最近更新 更多