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(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 |
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(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) |
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
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) |
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
# 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) |
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
### 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: |
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
gnr_resolve("American Crow") | |
# $results | |
# submitted_name matched_name data_source_title score | |
# 1 American Crow American Painted-snipe EOL 0.25 | |
# | |
# $preferred | |
# NULL |
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
n = 7 # Number of elements to permute | |
k = 1E5 # Number of permutations allowed by RNG | |
# Declare a character vector to store permutations | |
permutations = character(k) | |
for(i in 1:k){ | |
# save k permutations as strings | |
permutations[i] = paste(sample.int(n), collapse = "-") | |
} |
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
#Based on https://github.com/robotlolita/fuck-you | |
# and https://en.wikipedia.org/wiki/Transformation_of_text | |
screw_you = function(x){ | |
chars = strsplit(paste0(c(" ", rev(letters), rev(LETTERS), 0, 9:1, "&_?!\".';'"), collapse = ""), "")[[1]] | |
flipped = strsplit( | |
" zʎxʍʌnʇsɹbdouɯlʞɾıɥɓɟǝpɔqɐZ⅄XMΛ∩⊥SᴚΌԀONW⅂⋊ſIH⅁ℲƎᗡƆ𐐒∀068ㄥ9ގㄣƐᘔ⇂⅋‾¿¡„,˙'؛", | |
"")[[1]] | |
split = strsplit(as.character(substitute(x)), "")[[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
# Confirming that I understand how geiger's variance-covariance matrices work | |
library(geiger) | |
library(mvtnorm) | |
geo = get(data("geospiza")) | |
# Simulate one trait using geiger::sim.char | |
sim = t( |
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
f = function(x){ | |
x | |
} | |
f() # Throws error: x is missing | |
g = function(x){ | |
letters[x] | |
} |
OlderNewer