Skip to content

Instantly share code, notes, and snippets.

View jebyrnes's full-sized avatar

Jarrett Byrnes jebyrnes

View GitHub Profile
@jebyrnes
jebyrnes / pageviews.R
Created March 6, 2012 19:00
Analysis code for looking at the relationship between page views and dollars raised for #SciFund
source("./sciFundFunctions.r")
library(gridExtra)
############
#Begin with a plot of both with and without the outlier
############
viewsAll<-qplot(Pageviews, total, data=projects)+theme_bw(base_size=24) + ylab("Total Dollars Raised\n") +
xlab("\nPage Views") +
@jebyrnes
jebyrnes / Maestre_reanalysis.R
Created April 23, 2012 23:05
Code to Re-Analyze the results of Maestre et al 2012 Spurred on by Bob O'Hara, Jeremy Fox, and Ted Hart's ongoing discussions
########################################################################################################
# Re-Analysis of Maestre et al 2012
# examining relationship between biodiversity and ecosystem multifunctionality
# Paper and data included as a supplement can be found at http://dx.doi.org/10.1126/science.1215442
########################################################################################################
######################
####### First, let's look at standardized regression coefficients
####### Both for the best fit model, but also for the model averaged coefficients
######################
@jebyrnes
jebyrnes / martine.R
Created September 27, 2012 19:56
Martine's Code
enthus <- read.csv("enthusiasm.csv", header = TRUE)
# Plot the data
plot ( Chapters ~ Enthusiasm, data = enthus +
type = "p", pch = 20 +
main ="Holy Homework!" +
xlab = "Enthusiam units (week number)", xlim = c (0,3) + ylab = "Number of chapters", ylim = c (0,11))
# Fit regression line
abline (lm (Chapters ~ Enthusiasm, data = enthus))
# get equation for limera regression, R-squared and p-value
@jebyrnes
jebyrnes / hubway_dataviz.R
Created November 5, 2012 17:11
Visualize the Hubway Data
##################################################################################################################
######
###### Code to visualize the Hubway Data Set
###### for the Hubway Data Challenge
###### http://hubwaydatachallenge.org/
######
###### Jarrett Byrnes, http://jarrettbyrnes.info
######
###### Last Updated Nov 5, 2012
##################################################################################################################
@jebyrnes
jebyrnes / ma_senate_2012.R
Created November 6, 2012 20:41
MA Senate Projection
#load the excellent methods to query polls
#linked to at http://alandgraf.blogspot.com/2012/11/quick-post-about-getting-and-plotting.html
source("https://raw.github.com/dlinzer/pollstR/master/pollsterAPI.R")
#get the MA Senate Race
datMass <- pollstR(chart="2012-massachusetts-senate-brown-vs-warren",pages="all")
#reshape the data for plotting
library(reshape2)
dm <- melt.data.frame(datMass, id.vars=c("start.date", "N"), measure.vars=c("Warren", "Brown"))
@jebyrnes
jebyrnes / selectedOutput.Rmd
Created November 26, 2012 20:11
Show only selected pieces of the output from knitr.
# Show selected output
First we redefine the output hook:
```{r setup}
# the default output hook
hook_output = knit_hooks$get('output')
knit_hooks$set(output = function(x, options) {
if (!is.null(n <- options$out.lines)) {
if(length(n)==1) n<-c(n,n)
@jebyrnes
jebyrnes / method_comparison_LRR1.R
Created December 10, 2012 16:18
Compare Methods for Marine Meta-Analysis
#######################################################################################################################################
#
# Compare Different Types of Meta-Analysis Method
# for calculating an effect size from LRR1
#
# Jarrett Byrnes
# Last Updated Dec 9,2012 11am
#
# Changelog
#######################################################################################################################################
library(nlme)
library(ggplot2)
library(lubridate)
library(dplyr)
#download data from https://www.google.com/trends/explore#q=%22i%20cant%20even%22&cmpt=q&tz=Etc%2FGMT%2B5
i_cant_even <- read.csv("./i_cant_even.csv", skip=4)
#reformat weeks
i_cant_even$Week <- as.character(i_cant_even$Week)
@jebyrnes
jebyrnes / sciFundRoundByRound3.R
Created December 15, 2012 16:46
SciFund Round 3 Round by Round Comparison
r3 <- c(0L, 3000L, 1765L, 8645L, 6225L, 805L, 600L, 203L, 115L, 85L,
2700L, 1210L, 3790L, 2210L, 2135L, 610L, 5180L, 840L, 2200L,
410L, 1440L, 3080L, 1280L, 1165L, 4040L, 1110L, 6585L, 3015L,
2651L, 290L, 1990L, 0L, 810L, 5004L, 790L)
r1 <- c(1165L, 1129L, 2835L, 1000L, 5000L, 1120L, 1266L, 2100L, 1330L,
420L, 1070L, 128L, 1120L, 220L, 1075L, 1170L, 825L, 3000L, 1104L,
210L, 122L, 151L, 490L, 4600L, 2483L, 265L, 1565L, 1545L, 4110L,
10171L, 1000L, 1240L, 899L, 1320L, 848L, 605L, 970L, 545L, 1815L,
515L, 5085L, 450L, 755L, 1170L, 250L, 3243L, 1305L, 715L, 711L
@jebyrnes
jebyrnes / sampleAICNet.R
Last active December 16, 2015 04:09
Demo of otu-AIC code
####################################
### Demo of calculating LLs of
### group structures
### And plotting them using the network package
###
### Jarrett Byrnes
### Last updated: 4/11/2013
####################################
source("./getNetworkAIC.R")