发布于 2014-12-27 10:19:09 | 697 次阅读 | 评论: 0 | 来源: PHPERZ

这里有新鲜出炉的R语言教程,程序狗速度看过来!

R 数据统计分析语言

R是用于统计分析、绘图的语言和操作环境。R是属于GNU系统的一个自由、免费、源代码开放的软件,它是一个用于统计计算和统计制图的优秀工具。


本文为大家讲解的是如何在Redhat下安装R语言,感兴趣的同学参考下。

R语言简介

R是用于统计分析、绘图的语言和操作环境。R是属于GNU系统的一个自由、免费、源代码开放的软件,它是一个用于统计计算和统计制图的优秀工具。

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 


最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务