Skip to content

Instantly share code, notes, and snippets.

View cdesante's full-sized avatar

Christopher DeSante cdesante

  • Indiana University
View GitHub Profile
@cdesante
cdesante / breaks.r
Created November 12, 2012 23:15
custom breaks
toInstall <- c("ggplot2")
if(doInstall){install.packages(toInstall, repos = "http://cran.r-project.org")}
lapply(toInstall, library, character.only = TRUE)
library(ggplot2)
text.plots <- data.frame(
SUPP = c (rep(c( "Control", "Vitamin C", "Orange Juice" ), each = 1500)) ,
DOSE = rep(rep(c( "I", "II", "III" ), each=500), 3),
LENGTH = c(rnorm(500, 4, 2),
rnorm(500, 7, 1.2),
@cdesante
cdesante / textumble.r
Created September 14, 2012 15:30
Tex into Tumblr
Step 1: Go to the theme of your Tumblr account,
and add the following code snippet above the </head>:
<script type="text/javascript"
src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
Step 2: Use LaTeX as normal:
MathJax has two different ways to begin a TeX section,
@cdesante
cdesante / apsrtable.r
Created December 4, 2012 00:19
apsrtable
doInstall <- TRUE
toInstall <- c("apsrtable")
if(doInstall){install.packages(toInstall, repos = "http://cran.us.r-project.org")}
lapply(toInstall, library, character.only = TRUE)
#http://cran.r-project.org/web/packages/apsrtable/apsrtable.pdf
library(apsrtable)
@cdesante
cdesante / Rwords.r
Created December 17, 2012 16:01
Extracting Numeric Values from Words
My.Words <- read.csv("http://www.oberlin.edu/faculty/cdesante/assets/downloads/Randwords.csv")
My.Words$RANDOM.WORDS <- as.character(My.Words$RANDOM.WORDS)
#Step 1: Split Character Vectors into Sub-strings:
strsplit(My.Words$RANDOM.WORDS, "")
Split.List <- strsplit(My.Words$RANDOM.WORDS, "")
#Step 2: Assign a numeric value to each of the 26 letters:
LETTERS
@cdesante
cdesante / apsrtable.r
Created December 4, 2012 00:00
apsrtable
doInstall <- TRUE
toInstall <- c("apsrtable")
if(doInstall){install.packages(toInstall, repos = "http://cran.us.r-project.org")}
lapply(toInstall, library, character.only = TRUE)
#http://cran.r-project.org/web/packages/apsrtable/apsrtable.pdf
library(apsrtable)
@cdesante
cdesante / foreign.r
Created December 3, 2012 20:11
foreignR
doInstall <- TRUE
toInstall <- c("foreign")
if(doInstall){install.packages(toInstall, repos = "http://cran.us.r-project.org")}
lapply(toInstall, library, character.only = TRUE)
#http://cran.r-project.org/web/packages/foreign/foreign.pdf
#setwd("your working directory here")
library(foreign)
@cdesante
cdesante / happythanksgiving.r
Created November 21, 2012 01:22
Thanksgiving
toInstall <- c("ggplot2")
if(doInstall){install.packages(toInstall, repos = "http://cran.r-project.org")}
lapply(toInstall, library, character.only = TRUE)
library(ggplot2)
Turkey <- read.csv("http://www.oberlin.edu/faculty/cdesante/assets/downloads/turkey.csv")
ggplot(data = Turkey) + geom_tile(aes(x = Happy, y = Thanksgiving, fill=Turkey.Colors,
width=1))+ scale_fill_identity() + theme_bw()
@cdesante
cdesante / plottext2.r
Created November 14, 2012 05:48
plottext2
toInstall <- c("ggplot2")
if(doInstall){install.packages(toInstall, repos = "http://cran.r-project.org")}
lapply(toInstall, library, character.only = TRUE)
library(ggplot2)
text.plots <- data.frame(
SUPP = c (rep(c( "Control", "Vitamin C", "Orange Juice" ), each = 1500)) ,
DOSE = rep(rep(c( "I", "II", "III" ), each=500), 3),
LENGTH = c(rnorm(500, 4, 2),
rnorm(500, 7, 1.2),
@cdesante
cdesante / plottext3.r
Created November 14, 2012 04:53
plottext3
toInstall <- c("ggplot2")
if(doInstall){install.packages(toInstall, repos = "http://cran.r-project.org")}
lapply(toInstall, library, character.only = TRUE)
library(ggplot2)
text.plots <- data.frame(
SUPP = c (rep(c( "Control", "Vitamin C", "Orange Juice" ), each = 1500)) ,
DOSE = rep(rep(c( "I", "II", "III" ), each=500), 3),
LENGTH = c(rnorm(500, 4, 2),
rnorm(500, 7, 1.2),
@cdesante
cdesante / plottext1.r
Created November 14, 2012 04:57
plottext1
toInstall <- c("ggplot2")
if(doInstall){install.packages(toInstall, repos = "http://cran.r-project.org")}
lapply(toInstall, library, character.only = TRUE)
library(ggplot2)
text.plots <- data.frame(
SUPP = c (rep(c( "Control", "Vitamin C", "Orange Juice" ), each = 1500)) ,
DOSE = rep(rep(c( "I", "II", "III" ), each=500), 3),
LENGTH = c(rnorm(500, 4, 2),
rnorm(500, 7, 1.2),