Skip to content

Instantly share code, notes, and snippets.

Avatar

Brian A. Danielak briandk

View GitHub Profile
@briandk
briandk / geom-rug-alt-demonstration.R
Created Feb 20, 2011
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.
View geom-rug-alt-demonstration.R
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 Jul 29, 2011
Stitching together multiple CSV files in R
View stitchCSVs.R
TidyMultipleChoiceData <- function(file) {
multiple.choice.columns <- c("name",
"mc1",
"mc2",
"mc3",
"mc4",
"mc5",
"mc6",
"mc7",
"mc8"
@briandk
briandk / geomJitterVersusJitter.R
Created Aug 17, 2011
Three plots to show that geom_jitter() calls must pass a position=position_jitter() argument to preserve jittering width
View geomJitterVersusJitter.R
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 Aug 23, 2011
Making sure standard ggplot2 plots work as expected
View granovaGGTests.R
# 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 Sep 1, 2011
Comparing ggsave and the default pdf rendering in R
View ggsaveVersusPDF.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 Sep 1, 2011
Cycling granovaGG when package help won't load
View CyclingGranovaGG.R
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 Sep 2, 2011
Comparing F < 1 and F > 1 in granovaGG
View granovaGGFstatisticComparison.R
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 Sep 2, 2011
How an additional parser breaks my LaTeX code
View LaTeXparsingInRhelpFiles.tex
% 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 Oct 19, 2011
Why won't my strings work?
View scratchpad.c
#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 Nov 14, 2011
Experimenting with fscanf
View fscanf.c
#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;