Skip to content

Instantly share code, notes, and snippets.

@krlmlr
krlmlr / huntr.R
Created December 23, 2016 14:50
Detect and manually fix missing join-by columns for dplyr
withCallingHandlers(
remake::make(remake::list_targets()),
message = function(e) {
if (grepl("Joining, ", e$message)) {
by_clause <- gsub("Joining(.*)\n", "\\1", e$message)
clipr::write_clip(by_clause)
srcref <- testthat:::find_first_srcref(sys.calls()[-1:-15])
srcfile <- attr(srcref, "srcfile")$filename
rstudioapi::navigateToFile(srcfile, srcref[1], srcref[2])
stop("Insert by clause: ", by_clause)
@krlmlr
krlmlr / test-revdep.R
Last active August 24, 2016 15:11
Draft for testing revdep checks: https://github.com/hadley/devtools/issues/1302
#library(devtools)
devtools::load_all()
#' # Testing revdep_check()
#'
#' Functions:
create_deps_tested <- function() {
deps <- list(
testee = character(),
@krlmlr
krlmlr / rowwise.Rmd
Last active August 4, 2016 18:50 — forked from wch/rowwise.Rmd
---
title: "Applying a function over rows of a data frame"
author: "Winston Chang"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(collapse = TRUE, comment = "#>")
```
@krlmlr
krlmlr / gist:92007a8a8677fc56c87f
Created March 2, 2016 11:36
Offline GitHub issues, milestones, and labels, with wget
wget -np -k -e robots=off -r -l 1 https://github.com/krlmlr/tibble/milestones/ https://github.com/krlmlr/tibble/issues/ https://github.com/krlmlr/tibble/labels/
@krlmlr
krlmlr / deps.R
Created January 19, 2016 14:44
Module dependency graph for an R package
devtools::load_all()
envir <- as.environment("package:darn")
deps <- mvbutils::foodweb(where = envir, plotting = FALSE)
funmat <- deps$funmat
funs <- mget(colnames(funmat), envir, mode = "function")
fun_files <-
lapply(funs, attr, "srcref") %>%
template <class Fun>
class ScopeGuard {
Fun f_;
bool active_;
public:
ScopeGuard(Fun f)
: f_(std::move(f))
, active_(true) {
}
~ScopeGuard() { if (active_) f_(); }
@krlmlr
krlmlr / gist:80f5050a33e98de23671
Created April 14, 2015 21:25
Bootstrap wercker for R packages
curl http://krlmlr.github.io/makeR/install | sh
make dt_test
make init-wercker
make init-gh-pages
m1 <- png::readPNG("~/Downloads/m1.png")
m2 <- png::readPNG("~/Downloads/m2.png")
m1r <- m1[,,1]
m2r <- m2[,,1]
m1r1 <- m1r[,1]
m2r1 <- m2r[,1]
sim <- llply(
---
title: "Test"
output: html_document
---
```{r setup}
knitr::dep_prev()
summary(cars)
```
library(reshape2)
N <- 100000L
d.m <- data.frame(q1=runif(N), q2=runif(N), q3=runif(N),
f=sample(letters, N, replace=T), w=runif(N))
print(head(d.m))
print(summary(d.m))
sessionInfo()