Skip to content

Instantly share code, notes, and snippets.

View gertvv's full-sized avatar

Gert van Valkenhoef gertvv

View GitHub Profile
@gertvv
gertvv / install.sh
Created January 14, 2014 11:37
Installing R for package development on Ubuntu
#!/bin/sh
# The suggested packages are required to build documentation.
sudo apt-get install --install-suggests r-base-dev
@gertvv
gertvv / README.md
Last active January 3, 2016 02:39
User friendly tiling windows with xmonad on Ubuntu

xmonad on Ubuntu

Features

  • Windows key as the "Mod" key
  • Mod-p starts dmenu to run applications
  • Mod-L locks the screen (using gnome-screensaver)
  • Volume/mute keys supported
@gertvv
gertvv / 0README.md
Last active January 2, 2016 14:58
Run bwallace/abstrackr-web in Docker

Run Abstrackr using Docker

Prerequisites

You need docker.

Build

@gertvv
gertvv / checkMatrix.R
Created July 31, 2013 12:25
Check dynamic matrix indexing in R code. Sometimes, an expression like m[i:j, ] will return a matrix (when i != j) and otherwise a vector. This is a source of bugs in much of my R code. m[i:j, , drop=FALSE] explicitly disables this behavior. This gist contains R code to check your R code for matrix indexing operations that don't have drop= speci…
library(codetools)
addMatrixHandler <- function(fn) {
addCollectUsageHandler('[', 'base', fn)
}
myMatrixHandler <- function(e, w) {
w$enterGlobal("function", "[", e, w)
if (length(e) > 3 && !('drop' %in% names(e))) {
simple <- sapply(dropMissings(e[-(1:2)]), function(a) {
@gertvv
gertvv / readfile.html
Created July 25, 2013 15:07
Read a local file using the JavaScript / HTML [File API](http://www.w3.org/TR/FileAPI/ )
<html>
<head>
</head>
<body>
<script>
function loadJSON(form) {
console.log(form);
var files = form.file.files;
for (var i = 0; i < files.length; ++i) {
var file = files[i];
@gertvv
gertvv / rationale.md
Created February 19, 2013 09:20
Reasons for getting rid of rJava in GeMTC

Reasons for removing rJava from GeMTC

General concerns

  • Separating the code bases into a Java part and an R part makes the code less transparent and harder to contribute to. It also adds quite a bit of interfacing code (and headaches).

  • rJava is brittle

@gertvv
gertvv / lor.to.lrr.R
Created February 18, 2013 16:05
Convert GeMTC posterior samples for the log odds-ratio to samples for the log risk-ratio using an assumed baseline probability. The baseline could also be a vector of samples from a distribution for the baseline probability. For the given example probability (p = 0.3), the LRR and LOR differ substantially. For p = 0.01 they are nearly identical.
network <- ... # wherever your network comes from
model <- mtc.model(network)
result <- mtc.run(model)
result <- relative.effect(result, t1="A") # make sure everything is relative to the same reference
# transform the LOR to the LRR using an assumed probability for the reference treatment A
lor.to.lrr <- function(lor, p.A) {
lo.A <- log(p.A / (1 - p.A))
lo.B <- lo.A + lor # absolute log-odds of B
@gertvv
gertvv / 0001-Optionally-build-using-Maven.patch
Created March 17, 2012 11:22
Patch to build luaj-1.0.5 (j2se) using maven
From ceeb12b5737802006b6ca984ad2f45faf26db8ff Mon Sep 17 00:00:00 2001
From: Gert van Valkenhoef <g.h.m.van.valkenhoef@rug.nl>
Date: Sat, 17 Mar 2012 12:12:59 +0100
Subject: [PATCH] Optionally build using Maven
---
build.xml | 16 +++++++++++++
maven/core/pom.xml | 33 +++++++++++++++++++++++++++
maven/j2se/pom.xml | 38 +++++++++++++++++++++++++++++++
maven/pom.xml | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++