This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
########### | |
# Calculate a Dunnett's test | |
# using information from a meta-analysis | |
# using definitions at http://davidmlane.com/hyperstat/B112114.html | |
# | |
# Jarrett Byrnes | |
# 12/8/2013 | |
########### | |
#helper functions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#the range of possible snow | |
minsnow <- 0 | |
maxsnow <- 12 #1 foot - WOOOO!!! | |
#a range of snow values | |
snowdist <- seq(minsnow, maxsnow, 0.01) | |
len <- length(snowdist) | |
#let's assume a log normal distribution of the snow | |
#we might get, with a conservative mean of ~1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(Reol) | |
getOrder <- function(binom_taxa, db = "NCBI Taxonomy"){ | |
MyEOLs <- DownloadSearchedTaxa(binom_taxa, to.file=FALSE) | |
hier <- DownloadHierarchy(MyEOLs, FALSE, database=db) | |
taxonomic_info <- CombineHierarchyInfo(hier) | |
ord <- which(taxonomic_info[[2]]=="Order") | |
return(taxonomic_info[[1]][ord,1]) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################################ | |
# Problem: You have a ragged | |
# data frame where species that have not | |
# been seen as a site simply don't have a | |
# line in your data frame. You have a long | |
# data frame, but you want a long data frame | |
# where missing species have proper zeroes | |
# | |
# Solution: a combination of dcast and melt | |
# from the reshape2 package |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(multifunc) | |
library(wesanderson) | |
data(all_biodepth) | |
allVars<-qw(biomassY3, root3, N.g.m2, light3, N.Soil, wood3, cotton3) | |
germany<-subset(all_biodepth, all_biodepth$location=="Germany") | |
vars<-whichVars(germany, allVars) | |
#re-normalize N.Soil so that everything is on the same sign-scale (e.g. the maximum level of a function is the "best" function) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################################################################################ | |
# | |
# Script to turn lat/long data into | |
# marine ecoregions using Spalding's Marine Ecoregions | |
# of the World (MEOW). | |
# | |
# To run, first acquire the appropriate GIS files from | |
# http://maps.tnc.org/gis_data.html and unzip them into | |
# a directory (MEOW-TNC) - then go from there. | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(multifunc) | |
data(all_biodepth) | |
allVars<-qw(biomassY3, root3, N.g.m2, light3, N.Soil, wood3, cotton3) | |
germany<-subset(all_biodepth, all_biodepth$location=="Germany") | |
vars<-whichVars(germany, allVars) | |
#re-normalize N.Soil so that everything is on the same sign-scale (e.g. the maximum level of a function is the "best" function) | |
germany$N.Soil<- -1*germany$N.Soil +max(germany$N.Soil, na.rm=TRUE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\documentclass{article} | |
\begin{document} | |
<<echo=FALSE>>= | |
activityDF <- structure(list(julian_day = 1:365, food = c(92.6182247978374, | |
199.361820535986, 128.619308542186, 131.048504694701, 44.6344539529983, | |
139.02542881751, 118.815437972886, 85.5963235153311, 73.9459098960665, | |
85.6671795660157, 195.954639346317, 192.942941724749, 193.341526021202, | |
142.419581610027, 130.23002915561, 232.843857188757, 105.14817987285, | |
131.58751463704, 123.30056211349, 150.447279408636, 138.40775613945, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#just create a range of values | |
grdVals <- function(x, bound=0.01) seq(range(x)[1]-bound, range(x)[2]+bound, length.out=50) | |
#instantiate a new persp object for a scatterplot | |
makeScatterBox <- function(x,y,z, bound=0, ...){ | |
x <- grdVals(x, bound=bound) | |
y <- grdVals(y, bound=bound) | |
z <- grdVals(z, bound=bound) | |
z <- matrix(rep(z, 50), nrow=50) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
######################################################################### | |
# Code to import and make useful | |
# Spalding et al. 2007's Marine Ecoregions of the World | |
# Data provided by http://www.marineregions.org/downloads.php | |
# by Jarrett Byrnes | |
# last updated 3/26/2015 | |
######################################################################### | |
###################### | |
##### Load Libraries |