The Vim on the server is horribly outdated. Many of the things below won’t work, or will require extensive setup. In order to ease the pain, I suggest using the version installed and maintained by Micha via the [EBI-predoc config][config].
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
library(stringr) | |
library(BatchJobs) | |
library(plyr) | |
# Rationale | |
# This script uses BatchJobs to run functions either locally, on multiple cores, or LSF, | |
# depending on your BatchJobs configuration. It has a simpler interface, does more error | |
# checking than the library itself, and is able to queue different function calls. The | |
# function supplied *MUST* be self-sufficient, i.e. load libraries and scripts. | |
# BatchJobs on the EBI cluster is already set up when using the gentoo prefix. |
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
#!/bin/bash | |
# Wrapper script to run Vim-R-plugin R sessions as interactive jobs on LSF platforms. | |
# To use it, edit ~/.vimrc and add 'let vimrplugin_r_path = <path_to_script>' | |
# lets you deicde | |
echo What version of R do you want? | |
echo "1) R vX.X.X" | |
echo "2) R vZ.Z.Z" | |
echo "3) R vY.Y.Y" | |
read -t 60 -p '>' answer |
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
parsetidy <- function(x, ...) UseMethod("parsetidy") | |
parsetidy.default <- function(x, ...) { | |
# if it's not a call or name (e.g. it's numeric), | |
# don't need it | |
data.frame() | |
} | |
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
#!/usr/bin/env bash | |
# Inspired by <http://blog.melski.net/2010/11/30/makefile-hacks-print-the-value-of-any-variable/> | |
usage() { | |
echo >&2 "Usage: $0 [-f makefile] variables..." | |
echo >&2 | |
echo >&2 "Optional arguments:" | |
echo >&2 " -f makefile: path to the makefile" | |
echo >&2 |
In the following, let’s define sum
as
sum = function (a, b, c) a + b +c
Because base::sum
’s definition involves ...
, which would make the following explanation unnecessarily complex.
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
library(dplyr) | |
library(tidyr) | |
library(ggplot2) | |
stages = c('Ordered', '?', 'In transit', 'Arrived', 'Returned') | |
make_stages = function (status) | |
factor(status, levels = stages, ordered = TRUE) | |
pillows = tibble::tribble( |
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
#!/usr/bin/env bash | |
while getopts ":n:c:q:" option; do | |
case "$option" in | |
n) | |
cores="$OPTARG" | |
;; | |
m) | |
mem="$OPTARG" | |
;; |
Inspired by a Stack Overflow question, here’s a way of tracking what’s been modifying the .Random.seed
.
Since R makes static analysis impossible in general, the following is a runtime tracer that injects itself into the .Random.seed
variable via an active binding:
debug_random_seed()
sample(10)
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
importCpp <- function(infile, output_dir="lib", rebuild=FALSE){ | |
output_dir = ifelse(is.null(output_dir), ".", output_dir) | |
dir.create(output_dir, recursive=T, showWarnings=FALSE) | |
outfile = file.path(output_dir, paste0(infile, ".R")) | |
if (!file.exists(outfile) || file.info(infile)$mtime > file.info(outfile)$mtime || rebuild){ | |
Rcpp::sourceCpp(infile, rebuild=rebuild) | |
context = .Call("sourceCppContext", PACKAGE = "Rcpp", | |
normalizePath(infile, winslash = "/"), code=NULL, 0L, .Platform) | |
scriptfile = file.path(context$buildDirectory, context$rSourceFilename) |
OlderNewer