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 / tmup
Last active February 6, 2018 13:26 — forked from simonjbeaumont/tmup
Update bash to latest tmux environment on reattaching.
#!/bin/bash
tmup() {
local IFS=$'\n'
for line in $(tmux showenv -t $(tmux display -p '#S')); do
case $line in
-*) unset ${line:1} ;;
*) export $line ;;
esac
done
@klmr
klmr / Review.markdown
Last active August 29, 2015 13:56 — forked from mschubert/unix.R

Bugfixes

  • cmdescape fixes the use of parameters which contain special characters of the terminal (or spaces)
  • Regression: the updated version does not work with custom specified arguments. If this is desired, there should be an optional list parameter for this purpose.

Style fixes & Improvements

  • Single expressions do not need (and should not have) parentheses. This goes universally (and in particular, since R is a functional programming language, for functions).
  • There’s no need to forward %sed% to sed (and same for %grep%), it can be declared as an alias. In fact, the original function is somewhat redundant since operators can be called as functions.
  • Use `…` instead of '…' to specify unusual names: the former is syntactically a name while the latter is a string! It only “happens to work” because R has special lookup rules for functions when encountering a string. The same won’t work for other (non-function) objects though.