Skip to content

Instantly share code, notes, and snippets.

all: results.log
results.log: benchmark.R Makefile
r -p benchmark.R | tee results.log
@krlmlr
krlmlr / cut2.R
Last active December 11, 2015 11:28 — forked from mrdwab/cut2.R
cut2 <- function (x, breaks, labels = NULL, include.lowest = FALSE, right = TRUE,
dig.lab = 3, ordered_result = FALSE, ...)
{
if (!is.numeric(x))
stop("'x' must be numeric")
if (length(breaks) == 1L) {
if (is.na(breaks) || breaks < 2L)
stop("invalid number of intervals")
nb <- as.integer(breaks + 1)
dx <- diff(rx <- range(x, na.rm = TRUE))
dat <- read.table(text="VARIABLES DATE DATA
V1 1/03/2012 1000
V1 1/04/2012 1500
V1 1/12/2012 2600
V2 1/03/2012 900
V2 1/04/2012 1200
V2 1/12/2012 1000
V3 1/03/2012 200", header = TRUE)
@krlmlr
krlmlr / .autoscreen
Last active December 17, 2015 05:59 — forked from anonymous/.autoscreen
# Auto-screen invocation. see: http://taint.org/wk/RemoteLoginAutoScreen
# if we're coming from a remote SSH connection, in an interactive session
# then automatically put us into a screen(1) session. Only try once
# -- if $STARTED_SCREEN is set, don't try it again, to avoid looping
# if screen fails for some reason.
if [ "$TERM" != screen -a "$PS1" != "" -a "${STARTED_SCREEN:-x}" = x -a "${SSH_TTY:-x}" != x -a "$DISPLAY" == "" ]
then
echo "Auto-starting screen."
# Set the window title to HOSTNAME
@krlmlr
krlmlr / .screenrc-xpra
Created May 27, 2013 11:33
Files for integrating xpra with GNU Screen
!|sh -c "echo $DISPLAY > ~/.display-$(cat /etc/hostname)"
screen -t xpra 9 xpra start $DISPLAY --no-daemon
DROP TABLE IF EXISTS ind1_2000 CASCADE;
CREATE TABLE ind1_2000 (id integer, ind1 float);
ALTER TABLE ind1_2000 ADD PRIMARY KEY (id);
INSERT INTO ind1_2000 VALUES (1, 0.0);
INSERT INTO ind1_2000 VALUES (2, 0.3);
INSERT INTO ind1_2000 VALUES (3, 1.1);
VACUUM ANALYZE ind1_2000;
DROP TABLE IF EXISTS ind2_2000 CASCADE;
CREATE TABLE ind2_2000 (id integer, ind2 float);
@krlmlr
krlmlr / test.R
Created August 5, 2013 21:56
Test for failing lazy evaluation
.expr_to_fun <- function(x) {
expr <- substitute(x)
res <- force(x)
if (is.function(res)) {
list(f = res, val = res())
} else {
f <- eval.parent(substitute(function() expr))
list(f = f, val = res)
}
@krlmlr
krlmlr / xpra.conf
Last active December 20, 2015 16:59 — forked from anonymous/xpra.conf
#
# This is the default configuration file for Xpra
#
# You can provide default values for most command line
# options here.
# All options can be overriden on the xpra command line.
# See the man page for details.
# Options which can be turned on or off will accept
# the following values: 1, 0, true, false, yes, no
@krlmlr
krlmlr / xpra-attach-ssh
Last active December 20, 2015 16:59 — forked from anonymous/ivt-xpra
#!/bin/sh
ATTACH_TO=ssh:$1
echo -n "\033]0;xpra $1\007"
echo "Attaching to $ATTACH_TO..." >> /dev/stderr
xpra attach $ATTACH_TO
@krlmlr
krlmlr / .screenrc-xpra
Last active December 7, 2016 16:50 — forked from anonymous/-
screen -t xpra 9 xpra start $DISPLAY --no-daemon