https://www.digitalocean.com/community/tutorials/how-to-set-up-r-on-ubuntu-14-04
设置APT
$ sudo sh -c 'echo "deb http://cran.rstudio.com/bin/linux/ubuntu trusty/" >> /etc/apt/sources.list'
$ gpg --keyserver keyserver.ubuntu.com --recv-key E084DAB9
$ gpg -a --export E084DAB9 | sudo apt-key add -
安装
$ sudo apt-get update
$ sudo apt-get -y install r-base
测试
$ R
R version 3.2.1 (2015-06-18) -- "World-Famous Astronaut"
Copyright (C) 2015 The R Foundation for Statistical Computing
Platform: x86_64-pc-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.
>
退出:
> q(save = "no")
安装package
方式1:
$ R
> install.packages("somepackage")
方式2:
$ sudo su - -c "R -e \"install.packages('shiny', repos = 'http://cran.rstudio.com/')\""
注意repos
参数。
测试:
$ R
> library(shiny)
安装devtools包
有些包并不在CRAN中, 可以使用devtools安装。
安装:
$ sudo apt-get -y install libcurl4-gnutls-dev libxml2-dev libssl-dev
$ sudo su - -c "R -e \"install.packages('devtools', repos='http://cran.rstudio.com/')\""
使用devtools从Github中安装package
例如安装shinyjs包:
$ sudo su - -c "R -e \"devtools::install_github('daattali/shinyjs')\""
测试:
$ R
> library(shinyjs)