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/sh | |
# To use, place this script in your project .git/hooks directory. | |
# The script will automatically run travis-tool.sh run_tests before committing, so you won't break your project!. | |
# Modified from http://stackoverflow.com/questions/20479794/how-do-i-properly-git-stash-pop-in-pre-commit-hooks-to-get-a-clean-working-tree | |
# script to run tests on what is to be committed | |
# First, stash index and work dir, keeping only the | |
# to-be-committed changes in the working directory. | |
old_stash=$(git rev-parse -q --verify refs/stash) | |
git stash save -q --keep-index |
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
^figures/$ | |
^README\.Rmd$ |
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
#' --- | |
#' title: "Notebook Example" | |
#' author: "Jim Hester" | |
#' date: "`r Sys.Date()`" | |
#' output: rmarkdown::html_vignette | |
#' vignette: > | |
#' %\VignetteIndexEntry{Notebook example} | |
#' %\VignetteEngine{knitr::rmarkdown} | |
#' %\usepackage[utf8]{inputenc} | |
#' --- |
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
# missing variable | |
`$` <- function(x, y) { var = deparse(substitute(y)); if(!deparse(substitute(y)) %in% names(x)) { stop('missing variable: ', var) }; x[[var]] } | |
#> prob1<-as.data.frame(cbind(c(1,2,3),c(5,4,3))) | |
#> colnames(prob1)<-c("Education","Ethnicity") | |
#> table(prob1$Eduction, prob1$Ethnicity) | |
# Error in prob1$Eduction : wrong name: Eduction | |
# error when nrow is used on non data.frames or matrices | |
nrow <- function(x) { if (is.data.frame(x) || is.matrix(x)) { dim(x)[1L] } else { stop("nrow cannot be used on ", type(x)) } } |
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
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fpic -g -O0 -fprofile-arcs -ftest-coverage -c src/aes.c -o src/aes.o | |
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fpic -g -O0 -fprofile-arcs -ftest-coverage -c src/crc32.c -o src/crc32.o | |
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fpic -g -O0 -fprofile-arcs -ftest-coverage -c src/digest.c -o src/digest.o | |
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fpic -g -O0 -fprofile-arcs -ftest-coverage -c src/init.c -o src/init.o | |
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fpic -g -O0 -fprofile-arcs -ftest-coverage -c src/md5.c -o src/md5.o | |
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fpic -g -O0 -fprofile-arcs -ftest-coverage -c src/pmurhash.c -o src/pmurhash.o | |
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fpic -g -O0 -fprofile-arcs -ftest-coverage -c src/raes.c -o src/raes.o | |
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fpic -g -O0 -fprofile-arcs -ftest-coverage -c src/sha1.c -o src/sha1.o | |
gcc -std=gnu99 |
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
R Under development (unstable) (2015-05-13 r68364) -- "Unsuffered Consequences" | |
Copyright (C) 2015 The R Foundation for Statistical Computing | |
Platform: i386-w64-mingw32/i386 (32-bit) | |
R is free software and comes with ABSOLUTELY NO WARRANTY. | |
You are welcome to redistribute it under certain conditions. | |
Type 'license()' or 'licence()' for distribution details. | |
R is a collaborative project with many contributors. |
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
# DO NOT CHANGE the "init" and "install" sections below | |
# Download script file from GitHub | |
init: | |
ps: | | |
$ErrorActionPreference = "Stop" | |
Invoke-WebRequest http://raw.github.com/krlmlr/r-appveyor/master/scripts/appveyor-tool.ps1 -OutFile "..\appveyor-tool.ps1" | |
Import-Module '..\appveyor-tool.ps1' | |
install: |
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(microbenchmark) | |
a <- sample(letters, 1e6, TRUE) | |
b <- as.factor(a) | |
microbenchmark(c <- a[a == "d"], | |
d <- b[b == "d"], | |
e <- { | |
mtch <- match("d", levels(b)) | |
b[as.integer(b) == mtch] |
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
# benchmarks from http://www.win-vector.com/blog/2015/07/efficient-accumulation-in-r/#more-3295 | |
mkRow <- function(nCol) { | |
x <- as.list(rnorm(nCol)) | |
# make row mixed types by changing first column to string | |
x[[1]] <- ifelse(x[[1]]>0,'pos','neg') | |
names(x) <- paste('x',seq_len(nCol),sep='.') | |
x | |
} |
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(xml2) | |
date <- "2015-04-17" | |
tmp <- tempfile() | |
system2("svn", | |
args = c("log", | |
"-r", sprintf("{%s}:HEAD", date), | |
"--xml", | |
"-v"), | |
stdout = tmp) |