zoukankan      html  css  js  c++  java
  • R安装

    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 http://127.0.0.1:7964

    测试完毕!

  • 相关阅读:
    Appium python环境搭建
    打印各种三角形 正方形
    python学习笔记之---多进程实例
    selenium简介及发展
    python使用selenium自动化实现126邮箱登录的简单实例
    使用多进程访问网址的实例
    python学习笔记之---多进程【理论】
    爬虫设置定时任务
    python中eval和exec用法比较
    python使用文件处理加函数的方式写ATM简易操作
  • 原文地址:https://www.cnblogs.com/sjjsxl/p/5550901.html
Copyright © 2011-2022 走看看