[No.005]Redhat安装R语言

发布时间:2019-06-12 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了[No.005]Redhat安装R语言脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。

1、下载

wget http://mirror.bjtu.edu.cn/cran/src/base/R-3/R-3.0.1.tar.gz
#备份地址
[R3.01安装包][1]
http://pan.baidu.COM/s/1gdrbh4Z

2、解压:

tar -zxvf R-3.0.1.tar.gz
cd R-3.0.1

3、安装

yum install readline-devel
yum install libXt-devel
./configure
```shell

出现以下错误:
```shell
checking for g++... no
checking for c++... no
checking for gpp... no
checking for aCC... no
checking for CC... no
checking for cxx... no
checking for cc++... no
checking for cl.exe... no
checking for fcC... no
checking for KCC... no
checking for RCC... no
checking for xlC_r... no
checking for xlC... no
checking whether we are using the GNU C++ compiler... no
checking whether g++ accepts -g... no
checking how to run the C++ PReprocessor... /lib/cpp
configure: error: in `/Software/R/R-3.0.1':

发现是没有安装gcc编译器:

yum install gcc-c++

如果使用rJava需要加上 --enable-R-shlib

./configure  --enable-R-shlib --prefix=/usr/R-3.0.1
make
make install

4、配置环境变量

vi .bash_profile

PATH=/usr/R-3.0.1/bin

5、测试:创建脚本(t.R)

cd /opt/script/R
vim t.R


#!/path/to/Rscript    #第一行
x<-c(1,2,3)    #R语言代码
y<-c(102,299,301)
model<-lm(y~x)
summary(model)

6、测试:执行脚本

R CMD BATCH --args /opt/script/R/t.R
more /opt/script/R/t.Rout    #查看执行的结果
#或者第二种方式
Rscript /opt/script/R/test.R    #结果直接输出到终端
R version 3.0.1 (2013-05-16) -- "Good Sport"
Copyright (C) 2013 The R Foundation for Statistical Computing
Platform: i686-pc-linux-gnu (32-bit)

R是自由软件,不带任何担保。
在某些条件下你可以将其自由散布。
用'license()''licence()'来看散布的详细条件。

R是个合作计划,有许多人为之做出了贡献.
用'contributors()'来看合作者的详细情况
用'citation()'会告诉你如何在出版物中正确地引用R或R程序包。

用'demo()'来看一些示范程序,用'help()'来阅读在线帮助文件,或
用'help.start()'通过HTML浏览器来看帮助文件。
用'q()'退出R.

> #!/path/to/Rscript    #第一行
> x<-c(1,2,3)    #R语言代码
> y<-c(102,299,301)
> model<-lm(y~x)
> summary(model)

Call:
lm(formula = y ~ x)

Residuals:
    1     2     3 
-32.5  65.0 -32.5 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)
(Intercept)    35.00     121.60   0.288    0.822
x              99.50      56.29   1.768    0.328

Residual standard error: 79.61 on 1 degrees of freedom
Multiple R-squared:  0.7575,    Adjusted R-squared:  0.5151 
F-statistic: 3.124 on 1 and 1 DF,  p-value: 0.3278

> 
> proc.time()
 用户  系统  流逝 
0.306 0.032 0.334 

脚本宝典总结

以上是脚本宝典为你收集整理的[No.005]Redhat安装R语言全部内容,希望文章能够帮你解决[No.005]Redhat安装R语言所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。