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
# Plotting eigenvectors from PCA onto scatterplots | |
sigmat <- matrix(c(1,-.9,-.9,1), nrow=2) | |
cent <- c(8,3) | |
dat <- MASS::mvrnorm(n=100, mu=cent, Sigma=sigmat) | |
eig <- eigen(cov(dat)) | |
plot(dat, xlim=cent[1]+c(-3,3)*sigmat[1,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
require(XML) | |
scrapeBirdlife <- function(searchterm){ | |
webaddress <- paste("http://www.birdlife.org/datazone/sowbsearchresults.php?a=ns&SearchTerms", searchterm, sep='=') | |
aa <- readLines(webaddress) | |
# scrap only web address, common name, species name, IUCN status | |
aa <- aa[grep('species/factsheet', aa)] | |
aa <- gsub('<li><a href=\"','',aa) |
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
ubercoldist <- function(Qi, ni=c(1,2,2,4), w=0.2){ | |
Qi <- Qi[, 1:length(ni)] | |
Qi <- log(Qi) | |
e <- setNames(w/sqrt(ni), names(Qi)) | |
# prepare output | |
pairsid <- t(combn(nrow(Qi),2)) |
OlderNewer