######################################################## # Set up RStudio and JAGS on an Amazon EC2 instance # Using Ubuntu 64-bit # Christopher Gandrud # 16 December 2014 # Partially from http://blog.yhathq.com/posts/r-in-the-cloud-part-1.html # See yhat for EC2 instance set up ######################################################## # In your terminal navigate to key pair # ssh -i YOUR_KEYPAIR.pem ubuntu@PUBLIC_DNS # Get all programs up to date sudo apt-get update # Install latest g++ and clang sudo apt-get install gcc sudo apt-get install clang # Install prerequisites for RCurl sudo apt-get install libcurl4-openssl-dev # Check that you have the latest R installed ## see also: http://askubuntu.com/a/352438 sudo apt-get update apt-cache showpkg r-base # If R is not the latest version add latest PACKAGE_VERSION returned # from the pervious line to: sudo apt-get install -f r-base=PACKAGE_VERSION # Install rJava apt-get install r-cran-rjava # Install Stan and rstan # First find the number of cores lscpu # Load r, set cores, and install R Sys.setenv(MAKEFLAGS = "-j4") source('http://mc-stan.org/rstan/install.R', echo = TRUE, max.deparse.length = 2000) install_rstan() # Install other packages I often use ## Dependencies include reshape2, dplyr pkgs <- c('repmis', 'DataCombine', 'devtools') install.packages(pkgs) q() ######## Running Scripts and Downloading Results onto Local #### # Run a script so that it runs even if the terminal hands up # sudo nohup Rscript R_SCRIPT_PATH # Download a file from Amazon EC2 to your local machine # (current working directory) # scp -i YOUR_KEYPAIR.pem ubuntu@PUBLIC_DNS:EC2_FILE_PATH .