使用Shell脚本自动安装R-Studio

有什么办法可以在Linux系统上自动安装R-Studio? 它应该自动检测操作系统,并安装具有所需依赖项的R和R-Studio。 谢谢..

Solutions Collecting From Web of "使用Shell脚本自动安装R-Studio"

我准备了下面的shell脚本来使这个安装完全自动化。

#!/bin/bash # ****************************************** # Program: R-Studio Installation Script # Developer: Pratik Patil # Date: 16-04-2015 # Last Updated: 16-04-2015 # ******************************************** if [ "`lsb_release -is`" == "Ubuntu" ] || [ "`lsb_release -is`" == "Debian" ] then sudo apt-get -y install r-base gdebi-core libapparmor1; sudo wget http://download2.rstudio.org/rstudio-server-0.98.1103-amd64.deb; sudo gdebi rstudio-server-0.98.1103-amd64.deb; elif [ "`lsb_release -is`" == "CentOS" ] || [ "`lsb_release -is`" == "RedHat" ] then sudo yum -y install R openssl098e; sudo wget http://download2.rstudio.org/rstudio-server-0.98.1103-x86_64.rpm; sudo yum -y install --nogpgcheck rstudio-server-0.98.1103-x86_64.rpm; else echo "Unsupported Operating System"; fi sudo rm -f rstudio-server-*; sudo rstudio-server verify-installation; 

如何在Ubuntu或Debian系统中启动R-Studio? 在终端上输入以下命令:

 rstudio; 

如何在CentOS或RedHat系统中启动R-Studio? 在浏览器中打开以下URL:

 http://localhost:8787 

之后,登录提示符将出现,然后用当前系统用户凭证登录。

我使用它来安装R的当前版本以及Ubuntu(32或64位)上的RStudio预览版本,以及经常使用的pkgs:

 #!/bin/bash # this script can be run from the terminal with the next line (minus the #) # bash install_things.sh # you may need to enter your password at a few points, so keep an eye on it while it runs. # in case we need to step through: # set -x # trap read debug echo "install a few dependancies for our workflow" sudo apt-get update -y # sudo apt-get upgrade -y sudo apt-get install libgstreamer0.10-0 -y sudo apt-get install libgstreamer-plugins-base0.10-dev -y sudo apt-get install libcurl4-openssl-dev -y sudo apt-get install libssl-dev -y sudo apt-get install libopenblas-base -y sudo apt-get install libxml2-dev -y sudo apt-get install make -y sudo apt-get install gcc -y sudo apt-get install git -y sudo apt-get install pandoc -y sudo apt-get install libjpeg62 -y sudo apt-get install unzip -y sudo apt-get install curl -y sudo apt-get install littler -y sudo apt-get install openjdk-7-* -y sudo apt-get install gedit -y sudo apt-get install jags -y sudo apt-get install imagemagick -y sudo apt-get install docker-engine -y echo "edit the sources file to prepare to install R" # see http://cran.r-project.org/bin/linux/ubuntu/README sudo sh -c 'echo "deb http://cran.rstudio.com/bin/linux/ubuntu xenial/" >> /etc/apt/sources.list' # I'm using Lubuntu echo "get keys to install R" sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9 # # I'm using Lubuntu echo "install R and some helpers" sudo apt-get update sudo apt-get install r-base -y sudo apt-get install r-base-dev -y sudo apt-get install r-cran-xml -y sudo apt-get install r-cran-rjava -y sudo R CMD javareconf # for rJava echo "install RStudio from the web" # use daily build to get rmarkdown & latest goodies # http://stackoverflow.com/a/15046782/1036500 # check if 32 or 64 bit and install appropriate version... # http://stackoverflow.com/a/106416/1036500 MACHINE_TYPE=`uname -m` if [ ${MACHINE_TYPE} == 'x86_64' ]; then # 64-bit stuff here URL=$(wget -q -O - http://www.rstudio.org/download/daily/desktop/ubuntu64 | grep -o -m 1 "https[^\']*" ) FILE=`mktemp`; sudo wget "$URL" -qO $FILE && sudo dpkg -i $FILE; rm $FILE else # 32-bit stuff here URL=$(wget -q -O - http://www.rstudio.org/download/daily/desktop/ubuntu32 | grep -o -m 1 "https[^\']*" ) FILE=`mktemp`; sudo wget "$URL" -qO $FILE && sudo dpkg -i $FILE; rm $FILE fi echo "start R and install commonly used packages" # http://stackoverflow.com/q/4090169/1036500 # Make an R script file to use in a moment... LOADSTUFF="options(repos=structure(c(CRAN='http://cran.rstudio.com/'))) update.packages(checkBuilt = TRUE, ask = FALSE) packages <- c('codetools', 'Rcpp', 'devtools', 'knitr', 'ggplot2', 'plyr', 'dplyr', 'XML', 'RCurl', 'readxl', 'tidyr') # just some of my most often used ones install.packages(packages) # and some from github devtools::install_git(c('https://github.com/rstudio/rmarkdown.git', 'https://github.com/hadley/reshape'))" # close the R script # put that R code into an R script file FILENAME1="loadstuff.r" sudo echo "$LOADSTUFF" > /tmp/$FILENAME1 # Make a shell file that contains instructions in bash for running that R script file # from the command line. There may be a simpler way, but nothing I tried worked. NEWBASH='#!/usr/bin/env sudo Rscript /tmp/loadstuff.r' FILENAME2="loadstuff.sh" # put that bash code into a shell script file sudo echo "$NEWBASH" > /tmp/$FILENAME2 # run the bash file to exectute the R code and install the packages sh /tmp/loadstuff.sh # clean up by deleting the temp file rm /tmp/loadstuff.sh # done. echo "all done" echo "type 'sudo rstudio' in the terminal to start RStudio" 

这来自我的VM安装脚本: https : //gist.github.com/benmarwick/11204658