Skip to content

Instantly share code, notes, and snippets.

View davharris's full-sized avatar

David J. Harris davharris

View GitHub Profile
gnr_resolve("American Crow")
# $results
# submitted_name matched_name data_source_title score
# 1 American Crow American Painted-snipe EOL 0.25
#
# $preferred
# NULL
### Keybase proof
I hereby claim:
* I am davharris on github.
* I am harris (https://keybase.io/harris) on keybase.
* I have a public key whose fingerprint is 0867 7213 63D1 967B 2B0B E9E6 942D 033F 15ED 4389
To claim this, I am signing this object:
@davharris
davharris / mistnet-ordination.R
Created July 3, 2014 04:41
mistnet-ordination
# Install the most recent version of mistnet (if needed) using the devtools package
# devtools::install_github("davharris/mistnet")
library(mistnet)
# Grab a small data set from another package
library(ade4)
data(aviurba)
# Reduce the fauna table to ones and zeros
y = as.matrix(aviurba$fau > 0)
@davharris
davharris / boot.R
Created June 12, 2014 20:17
code for plotting bootstrap predictions from a nonlinear model
set.seed(1)
# Create fake data
x = runif(100, 0, 5)
y = .25 * x^3 - x^2 + rnorm(length(x))
data = data.frame(x = x, y = y)
# Identify 500 points to include in the plots
x.sequence = seq(0, 5, length = 500)
library(ggplot2)
library(mgcv)
# Something bad happens at t=400 and lambda drops
lambdas = c(runif(4E2, 6, 8), runif(1E2, 2, 4))
obs = rpois(length(lambdas), lambdas)
qplot(x = 1:length(obs), y = obs) +
stat_smooth(method = "gam", family = poisson, formula = y ~ s(x), size = 3)
library(MASS)
n = 1000
x = mvrnorm(n, c(0, 0), Sigma = matrix(c(1, .9, .9, 1), nrow = 2))
cor(x) # correlation of about 0.9 before thresholding
thresholded.values = x > 0
cor(thresholded.values) # Correlation drops to about 0.7, depending on random seed