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
# little animation to illustrate uncertainty in a density map | |
library(dsm) | |
library(mvtnorm) | |
library(ggplot2) | |
library(animation) | |
library(viridis) | |
# load the models and prediction data | |
# using data from the Duke spatial distance sampling course |
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(emoGG) | |
source("imgcat.R") | |
p <- ggplot(iris, aes(Sepal.Length, Sepal.Width, color = Species)) + geom_emoji(emoji="1f337") | |
imgcat(print(p)) |
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
# is Columbus, OH really the only place in the US where you're within | |
# 500 miles of half of the US population? | |
# claim: https://448f59f74df57015bbb8-a9447b7dfa4ae38e337b359963d557c4.ssl.cf3.rackcdn.com/9987%20Brewdog%20EFP%20Prospectus%20USA%20A4%20v9.pdf | |
# "Columbus is within 500 miles of over half of the US population" | |
# get the US 2010 census data | |
# http://www2.census.gov/geo/docs/reference/cenpop2010/county/CenPop2010_Mean_CO.txt | |
cent <- read.csv("CenPop2010_Mean_CO.txt") |
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
# try to understand measurements from the past... | |
# possible input types: | |
# - 5 | |
# - 5' | |
# - 5'5 | |
# - 5'7 1/2 | |
# - 5'7\" | |
# - 5'8.5 | |
# - 5'61/2\" |
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(gridBase) | |
library(grid) | |
library(mgcv) | |
library(statmod) | |
## nicer version of gam.check/rqgam.chack | |
# - deviance residuals for the Q-Q and histogram | |
# - RQR for resids vs linear pred | |
# - response vs fitted | |
# hist.p gives the quantiles of the residuals to show | |
better_check <- function(b, k.sample = 5000, k.rep = 200, rep = 0, level = 0.9, |
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
# make a boundary | |
library(mapdata) | |
library(maptools) | |
library(rgeos) | |
library(ggplot2) | |
library(sp) | |
# build the coastline | |
coastline <- map("world", c("USA", "Canada"), plot=FALSE) |
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
# for LJT | |
# this wasn't as simple as I thought, it was the summary() method that does the smart thing | |
# so there is a bit of split() nonsense to deal with... | |
library(Distance) | |
library(dsm) | |
library(ggplot2) | |
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(XML) | |
# pull in the xml file | |
# can export this from the iPhone and e-mail it to youself | |
xx <- xmlParse("export.xml") | |
xx <- xmlToList(xx) | |
# now do some data mudging | |
library(plyr) |
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
# how far did I go in 2017? | |
# read in the list of places I went to | |
txt <- readLines("howfar2017.txt") | |
# decode the place names to lat/long | |
library(ggmap) | |
gg <- geocode(txt, source="dsk") | |
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
### species discovery curve from eBird | |
library(lubridate) | |
# life list | |
life <- read.csv("ebird_world_life_list.csv") | |
life$date <- lubridate::dmy(as.character(life$Date)) | |
#sort | |
life <- life[order(life$date),] |