Skip to content

Instantly share code, notes, and snippets.

@dbuijs
dbuijs / DrugEvents.R
Created December 3, 2015 19:11
Canada Vigilance Drug Events By Active Ingredient
#ADR Event Detection
library(data.table)
library(lubridate)
library(dplyr)
library(stringr)
library(ggplot2)
library(purrr)
library(tidyr)
@dbuijs
dbuijs / chemspell.R
Created November 20, 2015 16:23
ChemSpell from R
#R script to access NIH ChemSpell Service
#Requires Github version of SSOAP 0.92-0, encoded branch
#Allows installation from Github
library(devtools)
#Just need to run this once to install the patched version of SSOAP
install_github("omegahat/SSOAP", ref = "use=encoded")
library(SSOAP)
@dbuijs
dbuijs / xmltodataframe.R
Created September 15, 2015 20:32
XML to dataframe
library(XML)
library(plyr)
wits <- "your/path/here/WITS.XML"
temp=xmlToList(wits, addAttributes = F)
df <- ldply(temp, .fun=function(x) {data.frame(t(unlist(x)))})
@dbuijs
dbuijs / ropenscibuild
Last active September 30, 2015 14:46
RopensciCreate
#! /bin/sh
#Run this file in the same dir as Dockerfile
sudo docker build -t my_ropensci .
sudo docker run --restart always -d -p 80:8787 -v /home/rstudio:/home/rstudio -e PASSWORD=[Insert Password Here] --name ropensci_server my_ropensci
@dbuijs
dbuijs / Dockerfile
Last active September 30, 2015 15:07
Dockerfile to add R packages
## Start with rocker/ropensci
FROM rocker/ropensci
MAINTAINER Daniel Buijs dbuijs@gmail.com
## Update repos
RUN apt-get update
## Install openBLAS
RUN apt-get install -y --no-install-recommends -t unstable \
libopenblas-dev
@dbuijs
dbuijs / ropensci
Last active August 29, 2015 14:23
ROpenSci
#! /bin/sh
### BEGIN INIT INFO
# Provides: ropensci
# Required-Start: $syslog
# Required-Stop: $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: ROpenSci Docker Image
# Description: This file starts and stops the ROpenSci Docker Image (to use, put in /etc/init.d/ and run sudo update-rc.d ropensci defaults)
#
@dbuijs
dbuijs / CreateSwap
Last active March 18, 2016 13:06
Create Swapfile
#! /bin/sh
#Create 2GB swapfile and activate
sudo install -o root -g root -m 0600 /dev/null /swapfile
fallocate -l 2g /swapfile
mkswap /swapfile
swapon /swapfile
echo "/swapfile swap swap auto 0 0" | sudo tee -a /etc/fstab
sudo sysctl -w vm.swappiness=10
echo vm.swappiness = 10 | sudo tee -a /etc/sysctl.conf