A few months ago I posted the script that I use to set up my R/JAGS working environment on an Amazon EC2 instance.
Since then I've largely transitioned to using R/Stan to estimate my models. So, I've updated my setup script (see below).
There are a few other changes:
I don't install/use RStudio on Amazon EC2. Instead, I just use R from the terminal. Don't get me wrong, I love RStudio. But since what I'm doing on EC2 is just running simulations (I handle the results on my local machine), RStudio is overkill.
I don't install git anymore. Instead I use
source_url
(from devtools) andsource_data
(from repmis) to source scripts from GitHub. Again all of the manipulation I'm doing to these scripts is on my local machine.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
######################################################## | |
# 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 . |
Comments
AWS Online Course
AWS Training
AWS Online Training
data science course in gurgaon