Roll your own iPython Notebook server with Amazon Web Services (EC2) using their Free Tier.
This file contains hidden or 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
packages <- c("devtools", | |
"data.table", | |
"lubridate", | |
"ggplot2", | |
"haven", | |
"readxl", | |
"tidyr", | |
"lme4", | |
"metafor", | |
"DiagrammeR", |
This file contains hidden or 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
install.packages("devtools") | |
library("devtools") | |
devtools::install_github("klutometis/roxygen") | |
library(roxygen2) | |
setwd("C:/Users/chanb/Documents/GitHub Repositories") | |
create("prepR") | |
setwd("./prepR") | |
document() |
This file contains hidden or 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
checkPackage <- function (pkg) { | |
# Check if pkg is installed; if not then install it; if an update exists then update | |
# Usage: | |
# > checkPackage("data.table") | |
if (is.character(pkg) == TRUE) { | |
repos <- "https://cloud.r-project.org" | |
if(pkg %in% rownames(installed.packages()) == FALSE) { | |
install.packages(pkg, repos=repos, dependencies=TRUE) | |
rowid <- which(installed.packages()[, "Package"] == pkg) | |
pkgInfo <- installed.packages()[rowid, ] |
This file contains hidden or 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
#Install in order to use RCurl & XML | |
sudo aptitude install libcurl4-openssl-dev | |
sudo apt-get install libxml2-dev |
This file contains hidden or 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
#Create a user, home directory and set password | |
sudo useradd rstudio | |
sudo mkdir /home/rstudio | |
sudo passwd rstudio | |
sudo chmod -R 0777 /home/rstudio | |
#Update all files from the default state | |
sudo apt-get update | |
sudo apt-get upgrade |
This file contains hidden or 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
################################################################################ | |
# | |
# R.nanorc -- nano syntax-highlighting file for R | |
# | |
# Origin: This file is part of the pkgutils package for R. | |
# | |
# Usage: This file should be placed in a directory such as /usr/share/nano/ (on | |
# Ubuntu 12.04). That nano uses syntax highlighting at all might need to be | |
# enabled separately. |
This file contains hidden or 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
body, td { | |
font-family: 'Lato', sans-serif; | |
background-color: white; | |
font-size: medium; | |
margin: 8px; | |
} | |
tt, code, pre { | |
font-family: Consolas, Monaco, monospace; | |
} |
This file contains hidden or 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
library(data.table) | |
nBins <- 25 | |
breaks <- seq(0, 1, length.out=nBins+1) | |
midpoints <- breaks[1:nBins] + (breaks[2:(nBins+1)] - breaks[1:nBins]) / 2 | |
D <- data.table(x = runif(1e4)) | |
D <- D[, xBinned := cut(x, breaks=breaks, labels=sprintf("%.2f", midpoints))] | |
D <- D[, | |
.(.N, | |
label=as.character(xBinned), | |
min = min(x), |