Skip to content

Instantly share code, notes, and snippets.

View klmr's full-sized avatar
📦
Making your R code easier to reuse

Konrad Rudolph klmr

📦
Making your R code easier to reuse
View GitHub Profile
@klmr
klmr / rs.r
Last active February 17, 2022 08:50
A versatile re-source file function for R
#' (Re-)source parts of a file
#'
#' \code{rs} loads, parses and executes parts of a file as if entered into the R
#' console directly (but without implicit echoing).
#'
#' @param filename character string of the filename to read from. If missing,
#' use the last-read filename.
#' @param from first line to parse.
#' @param to last line to parse.
#' @return the value of the last evaluated expression in the source file.
@hannic
hannic / ROT13.sh
Last active January 18, 2023 04:17
ROT13/ROT47 is an example of the Caesar cipher, developed in ancient Rome. Unix command. tr transliterate
# encode
tr 'A-Za-z' 'N-ZA-Mn-za-m' <<<"The Quick Brown Fox Jumps Over The Lazy Dog"
# decode
echo "Gur Dhvpx Oebja Sbk Whzcf Bire Gur Ynml Qbt" | tr '[A-Za-z]' '[N-ZA-Mn-za-m]'
@klmr
klmr / vim-notes.md
Created January 22, 2014 11:46
Notes for the seminar “Using Vim” for the Predoc Lunch Seminar series at EMBL-EBI.

Vim Notes

Setup

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].

@mschubert
mschubert / BatchJobsWrapper.R
Last active August 29, 2015 13:57
Wrapper for the BatchJobs library that simplifies the interface and performs more checks
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.
@tleonardi
tleonardi / bobR.sh
Created May 22, 2014 10:21
Wrapper script to run Vim-R-plugin R sessions as interactive jobs on LSF platforms
#!/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
#include "mach_gettime.h"
#include <mach/mach_time.h>
#define MT_NANO (+1.0E-9)
#define MT_GIGA UINT64_C(1000000000)
// TODO create a list of timers,
static double mt_timebase = 0.0;
static uint64_t mt_timestart = 0;
# Hello, and welcome to makefile basics.
#
# You will learn why `make` is so great, and why, despite its "weird" syntax,
# it is actually a highly expressive, efficient, and powerful way to build
# programs.
#
# Once you're done here, go to
# http://www.gnu.org/software/make/manual/make.html
# to learn SOOOO much more.
@klmr
klmr / gun-deaths.rmd
Last active May 5, 2022 11:19
Gun ownership vs gun deaths reanalysis
---
author: "<a href=\"http://twitter.com/klmr\">@klmr</a>"
title: "Gun deaths and gun ownership in the USA"
date: 2015-06-19
output:
html_document:
theme: readable
---
```{r echo=FALSE}
library(dplyr, warn.conflicts = FALSE, quietly = TRUE)
@hrbrmstr
hrbrmstr / gist_comments_feed.R
Last active February 24, 2018 13:52
GitHub Gist Comments Feed Generator in R (this is how much I hate Ruby)
# Roll your own GitHub Gist Comments Feed in R
library(xml2) # github version
library(rvest) # github version
library(stringr) # for str_trim & str_replace
library(dplyr) # for data_frame & bind_rows
library(pbapply) # free progress bars for everyone!
library(XML) # to build the RSS feed
who <- "hrbrmstr" # CHANGE ME!
@dgrtwo
dgrtwo / parsetidy.R
Last active September 16, 2015 09:10
Some thoughts on a parsetidy function that turns expressions into tidy data frames, and further processes them (for use in reprex package)
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()
}