- htttp://www.pearselab.com/
- @willpearse
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
#Headers | |
require 'open-uri' | |
require 'nokogiri' | |
require 'set' | |
#Get all the penalty stats | |
results = [] | |
(2011..2014).to_a.each do |year| | |
(0..30).to_a.map{|x| x * 40 + 1}.each do |player_count| | |
page = Nokogiri::HTML(open("http://espn.go.com/nhl/statistics/player/_/stat/minor-penalties/sort/minorPenalties/year/#{year}/seasontype/2/count/#{player_count}")) |
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
#Headers | |
require(geiger) | |
require(phytools) | |
require(nlme) | |
#Wrappers | |
get.lam <- function(x) attr(x$apVar, "Pars")[1] | |
get.vars <- function(n, lam){ | |
tree <- rcoal(n=n) | |
x <- fastBM(geiger::rescale(tree, 'lambda', lambda = lam),sig2=0.5) # Brownian motion |
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
#!/usr/bin/ruby | |
require 'optparse' | |
require 'json' | |
require 'open-uri' | |
require 'nokogiri' | |
############################ | |
# ARGUMENT PARSING ######### | |
############################ | |
options = {} |
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
#Loading a package | |
library(pez) | |
#Building a tree | |
tree <- read.tree("Vascular_Plants_rooted.dated.tre") #file from http://datadryad.org/resource/doi:10.5061/dryad.63q27 | |
species <- c("Quercus_notreal","Pinus_notreal","Blasia_notreal","Riccia_notreal") | |
tree <- congeneric.merge(tree, species) | |
tree <- drop.tip(tree, setdiff(tree$tip.label, species)) | |
#Calculating PD |
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
# Functions | |
library(caper) | |
find.clade <- function(tree, tips){ | |
clade.mat <- clade.matrix(tree)$clade.matrix | |
sums <- rowSums(clade.mat) | |
ancestors <- apply(clade.mat, 1, function(x) all(x[tips]==1)) | |
sums[!ancestors] <- length(tree$tip.label) | |
return(unname(which.min(sums))) | |
} | |
bind.replace <- function(backbone, donor, replacing.tip.label){ |
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
# Headers | |
library(pez) | |
data(laja) | |
############################# | |
# SETUP ##################### | |
############################# | |
# Make a comparative community object from a phylogeny and some | |
# site-species community data - some invertebrates found in some |
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
# PICS and PGLS - oh my! | |
# Will Pearse - 2018-04-03 | |
# Headers | |
library(ape) | |
library(caper) | |
library(geiger) | |
library(phytools) | |
library(mvMORPH) |
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
#!/usr/bin/ruby | |
require 'optparse' | |
require 'csv' | |
options = {} | |
OptionParser.new do |opts| | |
#Defaults | |
options[:output] = nil | |
options[:input] = nil | |
options[:lat] = "lat" |
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
# Packages | |
library(geiger) | |
library(caper) | |
library(phytools) | |
# Simulate phylogeny and some traits | |
tree <- sim.bdtree(n=100) | |
traits <- sim.char(tree, .01, nsim=7)[,1,] | |
# Fuss around to make a discrete character |
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
#' @export | |
.reed.2017a <- function(...) { | |
data <-read.csv("http://pasta.lternet.edu/package/data/eml/knb-lter-sbc/17/30/a7899f2e57ea29a240be2c00cce7a0d4", as.is=TRUE) | |
names(data) <- tolower(names(data)) | |
data$count[data$count < 0] <- 0 | |
data$taxon_species[data$taxon_species == -99999] <- NA | |
data$taxon_genus[data$taxon_genus == -99999] <- NA | |
data$species <- with(data, paste(taxon_genus, taxon_species, sep="_")) |
OlderNewer