Skip to content

Instantly share code, notes, and snippets.

View briandk's full-sized avatar

Brian A. Danielak briandk

View GitHub Profile
@briandk
briandk / scaleFillManualProblems.R
Created February 8, 2012 03:52
Problems with scale_fill_manual in ggplot2 v0.9.0
# These problems are current as of
# commit fe93b8ae11c43f8e33cb0252a25d260a769d4ded in ggplot2
# A data frame with four levels of 'g'
dat2 <- data.frame(x=factor(1:5),
y=3,
g=c("B","A","C","D","D"))
p2 <- ggplot(dat2, aes(x=x,y=y,fill=g)) + geom_bar()
@briandk
briandk / printFourPlotsPerPageTest.R
Created February 22, 2012 23:33
Testing print.four.plots.per.page
library(granovaGG)
# Explicitly printing four plots per page
pdf(file="~/Desktop/BrianTest1.pdf", onefile = TRUE)
data(rat)
fake.contrasts <- matrix(c(1, 1, 1, -1, -1, -1, -1, 1, 0, -1, 1, 0, 1, 1, -2,
1, 1, -2, -1, 1, 0, 1, -1, 0, 1, 1, -2, -1, -1, 2), ncol = 5)
fake.contrasts <- fake.contrasts[ ,1:3]
granovagg.contr(data = rat[ ,1],
@briandk
briandk / parameterMatching.R
Created February 23, 2012 17:10
Fun with parameter matching in R
foo <- function(..., values) {
return(values)
}
bar <- function(values, ...) {
return(values)
}
# foo() will fail to match on "values" and claim there's no default
foo(value = "red")
@briandk
briandk / granovaGGpre-commit.sh
Created May 16, 2012 16:53
precommit hook for granovaGG git repository
#!/bin/bash
D=`date +%Y%m%d%H%M%S` # store the current system-clock as a date-stamp, down to the second
branch=`git status|grep -ie 'on branch master'`
if [ -z "$branch" ]; then # if the length of the string in variable "branch" is zero;
# or, in other words, if you're not on the master branch
cat DESCRIPTION | sed -e 's/^\(Version: [0-9]*\.[0-9]*\).*/\1.'$D'/' > DESCRIPTION.temp # cat the DESCRIPTION
# match on the version number
# append the full datestamp to the matched version number
test<-data.frame(a=c(2,2,2,4,4,4,4,6,6,6,6,6,6,8,8,8,10,10,10,10,10,10,10),Pre=c(100,110,90,100,120,130,170,150,150,120,140,150,120,90,90,100,40,50,40,40,20,60,30),Post=c(b-15))
testMelt <- melt(
test,
id = c("a"),
measured = c("Pre", "Post")
)
p <- ggplot(
@briandk
briandk / wringing-water-from-clothes.ipynb
Last active October 14, 2015 04:08
A real-life physics problem I had when my washer broke
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@briandk
briandk / position-details.md
Created October 23, 2015 19:04
A CSEd position at the University of Nebraska–Omaha
@briandk
briandk / improving-bibtex-autocomplete.md
Last active October 26, 2015 03:33
Improving bibtex-autocomplete for atom
@briandk
briandk / trying_to_reproduce_CRAN_errors.md
Last active December 2, 2015 20:31
I can't reproduce CRAN's package-check errors for granovaGG v. 1.4.0. This VM is my way of trying to figure out whether I'm crazy.

Background

After I submitted my package to CRAN yesterday, Uwe Ligges sent me a kind email letting me know CRAN was seeing NOTEs in its package check process. A classic problem for R package maintainers: we can't reproduce the package-check errors CRAN sees.

What I tried to do to reproduce the errors CRAN sees

I built an entire VM, essentially from scratch, that anyone with Vagrant and VirtualBox can run. My package passes all the checks with only one NOTE (about bypassing cyclic dependency checks).

How to reproduce things from my end

@briandk
briandk / UsingLaTeXinRMarkdown.Rmd
Created December 7, 2015 19:47
Rmarkdown is happy to take raw Markdown code. And, you can also include other LaTeX files to your heart's content using the YAML metadata block up top.
---
title: "Tufte Handout"
author: "John Smith"
date: "August 13th, 2014"
output: rmarkdown::tufte_handout
---
# Introduction
The Tufte-\LaTeX\ [^tufte_latex] document classes define a style similar to the style Edward Tufte uses in his books and handouts. Tufte's style is known for its extensive use of sidenotes, tight integration of graphics with text, and well-set typography.