|
参考网址:http://blog.itpub.net/21711990/viewspace-1114418/
http://blog.sina.com.cn/s/blog_8353c4e90102vp1j.html
1、下载
wget http://mirror.bjtu.edu.cn/cran/src/base/R-3/R-3.0.1.tar.gz
https://cran.r-project.org/src/base/R-3/ 其他版本
2、解压:
tar -zxvf R-3.0.1.tar.gz
cd R-3.0.1
3、安装 (当然也可以跳过)
yum install readline-devel
yum install libXt-devel
./configure
4、 配置环境并编译安装
# 如果使用rJava需要加上 --enable-R-shlib (这个我不需要,所以加入到后面)
# 如果3没安装, 那么后面加上: --with-readline=no --with-x=no
./configure --prefix=/media/l/app/spark/R/install --enable-R-shlib=yes --with-libpng-x=no --with-tcltk
要支持 rstition 要加上 --enable-R-shlib=yes --with-libpng-x=no --with-tcltk
make $$ make install
5、配置环境变量并生效
vi .bash_profile
export R_HOME=/usr/R-3.0.1
export PATH=.:$R_HOME/bin:$PATH
# 试环境变量生效
source .bash_profile
6、 命令行测试
[admin@JD software]$ R
WARNING: ignoring environment value of R_HOME
R version 3.0.1 (2013-05-16) -- "Good Sport"
Copyright (C) 2013 The R Foundation for Statistical Computing
Platform: x86_64-unknown-linux-gnu (64-bit)
R是自由软件,不带任何担保。
在某些条件下你可以将其自由散布。
用'license()'或'licence()'来看散布的详细条件。
R是个合作计划,有许多人为之做出了贡献.
用'contributors()'来看合作者的详细情况
用'citation()'会告诉你如何在出版物中正确地引用R或R程序包。
用'demo()'来看一些示范程序,用'help()'来阅读在线帮助文件,或
用'help.start()'通过HTML浏览器来看帮助文件。
用'q()'退出R.
> q()
7、创建脚本测试(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)
8、测试:执行脚本
R CMD BATCH --args /opt/script/R/t.R
more /opt/script/R/t.Rout #查看执行的结果
或者第二种方式
Rscript /opt/script/R/test.R #结果直接输出到终端
网上提示:
recompile with -fPIC
重新运行:
[root@IPZHWG-AAA-01 resin]# CFLAGS="-fPIC"
++
make clean 后
./configure --prefix=/media/l/app/spark/R/install --with-readline=no --with-x=no --enable-R-shlib=yes --enable-shared
# make
# make install
~/.bashrc
export R_HOME=/media/l/app/spark/R/install
export PATH=.:$R_HOME/bin:$PATH
用 qqplot2 绘画 有问题 报错
Semi-transparency in RStudio
had exactly the same problem as the OP, but in my case setting options(bitmapType="cairo")
did not solve the problem.
In my case the problem was caused by the fact that I compiled R manually from source without the --with-cairo
configure option (or rather: my system was lacking the necessary libcairo2-dev package, the --with-cairo
did not have any effect). Recompiling R with proper cairo support fixed the issue. It now even works although getOption("bitmapType")
is still set to `"Xlib".