Skip to content

Instantly share code, notes, and snippets.

@JohnMount
JohnMount / base_fns.R
Created Mar 23, 2018
Small strengthenings of base R functions to be more pipe compatible.
View base_fns.R
# Re-expose basic R data manipulation tools in more pipe friendly wrappers.
library("wrapr")
#' Evaluate an expression with a data frame acting as the inner environment.
#'
#' References can be forced to the environment with a .e$ prefix
#' and forced to the data frame with a .d$ prefix (failure to
#' lookup returns null). Only works on in-memory data.frames.
@JohnMount
JohnMount / confEc2RServer.bash
Last active Sep 6, 2021
Configure an Amazon EC2 instance to serve a tunneled RStudio Server instance (from a Unix client)
View confEc2RServer.bash
#!/bin/bash
# on local
pempath="$1"
ec2target="$2"
ssh -T -i "${pempath}" -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ubuntu@${ec2target} << 'EOBLOCK'
# on remote machine
sudo apt-get -y update
sudo apt-get -y upgrade
View h2o.R
# The following two commands remove any previously installed H2O packages for R.
if ("package:h2o" %in% search()) { detach("package:h2o", unload=TRUE) }
if ("h2o" %in% rownames(installed.packages())) { remove.packages("h2o") }
# Next, we download packages that H2O depends on.
pkgs <- c("methods","statmod","stats","graphics","RCurl","jsonlite","tools","utils")
for (pkg in pkgs) {
if (! (pkg %in% rownames(installed.packages()))) { install.packages(pkg) }
}