博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
R安装
阅读量:4315 次
发布时间:2019-06-06

本文共 2615 字,大约阅读时间需要 8 分钟。

linux:

在编译R之前,需要通过yum安装以下几个程序:

#yum install gcc-gfortran              #否则报”configure: error: No F77 compiler found”错误

#yum install gcc gcc-c++              #否则报”configure: error: C++ preprocessor “/lib/cpp” fails sanity check”错误

#yum install readline-devel          #否则报”–with-readline=yes (default) and headers/libs are not available”错误

#yum install libXt-devel                 #否则报”configure: error: –with-x=yes (default) and X11 headers/libs are not available”错误

wget http://mirror.bjtu.edu.cn/cran/src/base/R-3/R-3.0.1.tar.gz
 
2、解压:
tar -zxvf R-3.0.1.tar.gz
cd R-3.0.1
 
3、安装
yum install readline-devel
yum install libXt-devel
./configure
 
如果使用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
source .bash_profile
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    #结果直接输出到终端
 
 

测试:

[root@192 R-3.1.1]# R

R version 3.1.1 (2014-07-10) -- "Sock it to Me"

Copyright (C) 2014 The R Foundation for Statistical Computing

Platform: x86_64-unknown-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.

You are welcome to redistribute it under certain conditions.

Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.

Type 'contributors()' for more information and

'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or

'help.start()' for an HTML browser interface to help.

Type 'q()' to quit R.

> head(iris)

  Sepal.Length Sepal.Width Petal.Length Petal.Width Species

1          5.1         3.5          1.4         0.2  setosa

2          4.9         3.0          1.4         0.2  setosa

3          4.7         3.2          1.3         0.2  setosa

4          4.6         3.1          1.5         0.2  setosa

5          5.0         3.6          1.4         0.2  setosa

6          5.4         3.9          1.7         0.4  setosa

尝试安装shiny包

> install.packages("shiny")

Selection: 20

also installing the dependencies ‘Rcpp’, ‘bitops’, ‘httpuv’, ‘caTools’, ‘RJSONIO’, ‘xtable’, ‘digest’, ‘htmltools’

trying URL 'http://mirror.bjtu.edu.cn/cran/src/contrib/Rcpp_0.11.2.tar.gz'

Content type 'application/octet-stream' length 2004313 bytes (1.9 Mb)

opened URL

==================================================

downloaded 8734 bytes

trying URL 'http://mirror.bjtu.edu.cn/cran/src/contrib/httpuv_1.3.0.tar.gz'

Content type 'application/octet-stream' length 423739 bytes (413 Kb)

opened URL

> library(shiny)

> runExample("01_hello")

Listening on 

测试完毕!

转载于:https://www.cnblogs.com/sjjsxl/p/5550901.html

你可能感兴趣的文章
SAM4E单片机之旅——24、使用DSP库求向量数量积
查看>>
从远程库克隆库
查看>>
codeforces Unusual Product
查看>>
hdu4348 - To the moon 可持久化线段树 区间修改 离线处理
查看>>
springMVC中一个class中的多个方法
查看>>
Linux系统安装出错后出现grub rescue的修复方法
查看>>
线段树模板整理
查看>>
[教程][6月4日更新]VMware 8.02虚拟机安装MAC lion 10.7.3教程 附送原版提取镜像InstallESD.iso!...
查看>>
[iOS问题归总]iPhone上传项目遇到的问题
查看>>
Python天天美味(总) --转
查看>>
Spring Framework tutorial
查看>>
【VS开发】win7下让程序默认以管理员身份运行
查看>>
【机器学习】Learning to Rank 简介
查看>>
Unity 使用实体类
查看>>
【转】通过文件锁实现,程序开始运行时,先判断文件是否存在,若存在则表明该程序已经在运行了,如果不存在就用open函数创建该文件,程序退出时关闭文件并删除文件...
查看>>
MySQL常见注意事项及优化
查看>>
流畅的Python (Fluent Python) —— 前言
查看>>
Jquery-menu-aim流畅的菜单滑动体验
查看>>
Jquery EasyUI修改行背景的两种方式
查看>>
生成器模式(Builder)C++实现
查看>>