Skip to content

Instantly share code, notes, and snippets.

View briandk's full-sized avatar

Brian A. Danielak briandk

View GitHub Profile
@briandk
briandk / geom-rug-alt-demonstration.R
Created February 20, 2011 15:47
This file demonstrates that a new ggplot2 geom I've created--which puts rug fringes on the top/right--seems to plot just fine when sourced from a single script.
geom_rug_alt <- function(mapping = NULL,
data = NULL,
stat = "identity",
position = "identity",
...
)
{
GeomRugAlt$new(mapping = mapping,
data = data,
stat = stat,
@briandk
briandk / stitchCSVs.R
Created July 29, 2011 20:29
Stitching together multiple CSV files in R
TidyMultipleChoiceData <- function(file) {
multiple.choice.columns <- c("name",
"mc1",
"mc2",
"mc3",
"mc4",
"mc5",
"mc6",
"mc7",
"mc8"
@briandk
briandk / geomJitterVersusJitter.R
Created August 17, 2011 21:27
Three plots to show that geom_jitter() calls must pass a position=position_jitter() argument to preserve jittering width
library(ggplot2)
set.seed(1001)
x <- rep(0, times = 1000)
x.jittered <- jitter(x, amount = 2)
y <- rnorm(1000)
dd <- data.frame(x, x.jittered, y)
p1 <- ggplot()
@briandk
briandk / granovaGGTests.R
Created August 23, 2011 02:02
Making sure standard ggplot2 plots work as expected
# Check whether ggplot2 plots produce the same behavior
library(ggplot2)
qplot(hwy, cty, data = mpg, main = "Plot of City Mileage vs. Highway Mileage")
@briandk
briandk / ggsaveVersusPDF.R
Created September 1, 2011 03:58
Comparing ggsave and the default pdf rendering in R
# Making sure you have a fresh copy of granovaGG
remove.packages("granovaGG", lib = .libPaths())
library(devtools)
install_github(repo = "granovaGG", username = "briandk", branch = "dev")
library(granovaGG)
library(granova)
# Creating a 7-inch by 7-inch test plot
setwd("~/Desktop/testplots") # I created the testplots directory in advance
granovagg.1w(data = mpg$hwy, group = mpg$manufacturer)
@briandk
briandk / CyclingGranovaGG.R
Created September 1, 2011 04:16
Cycling granovaGG when package help won't load
detach(package:granovaGG) # this may throw an error
remove.packages("granovaGG", lib = .libPaths())
### QUIT AND RESTART R.APP
library(devtools)
install_github(repo = "granovaGG", username = "briandk", branch = "dev")
library(granovaGG)
?granovagg.1w
@briandk
briandk / granovaGGFstatisticComparison.R
Created September 2, 2011 18:52
Comparing F < 1 and F > 1 in granovaGG
set.seed(1001)
library(granovaGG)
data(arousal)
# Red boxes for F < 1
granovagg.1w(rnorm(100,10,2),rep(1:4,ea=25), main = "Random Data with F < 1")
# Blue boxes for F > 1
granovagg.1w(chickwts$weight, group = chickwts$feed, main = "Chickwts Data with F > 1")
@briandk
briandk / LaTeXparsingInRhelpFiles.tex
Created September 2, 2011 20:04
How an additional parser breaks my LaTeX code
% This is how it should look
\eqn{LaTeX code goes here}{%ASCII fallback text goes here
}
% This is what it looks like after a parser forcibly applies a hard line break
\eqn{LaTeX code goes here}{%ASCII fallback
text goes here
}
@briandk
briandk / scratchpad.c
Created October 19, 2011 20:37
Why won't my strings work?
#include <stdio.h>
void blank_string (char *s) {
int i = 0;
for (i = 0; i < 10; i = i + 1) {
*(s + i) = "5";
}
*(s + 10) = "\0";
}
@briandk
briandk / fscanf.c
Created November 14, 2011 04:20
Experimenting with fscanf
#include <stdio.h>
int x;
int main (int argc, char const *argv[])
{
FILE *myFile = fopen("passenger.small.txt", "r");
char myString[1000];
int int1 = 0;
int int2 = 0;