This file contains hidden or 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 <- 200 | |
add_layer <- function(coords=data.frame(x=0, y=0), layer=0){ | |
so_rad <- seq(0, 2*pi-0.1, len=n) | |
if(layer==0){ | |
lens0 <- 0.1*runif(1, 0.1, 1) |
This file contains hidden or 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
## this code makes figure captions work in HTML output | |
# adapted from http://gforge.se/2014/01/fast-track-publishing-using-knitr-part-iii/ | |
library(knitr) | |
options(figure_counter = TRUE) | |
# Evaluate the figure caption after the chunk, | |
# sometimes you want to calculate stuff inside the | |
# chunk that you want to include in the caption and | |
# it is therefore useful to evaluate it afterwards. |
This file contains hidden or 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/env bash | |
# David L Miller | |
# updated 28 February 2019 | |
# taken from: | |
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx | |
# https://twitter.com/chadwhitaker/status/1004441991415922688 | |
# https://www.idownloadblog.com/2014/08/03/how-to-remove-the-shadow-window-screenshots-on-mac-os-x/ | |
# and elsewhere |
This file contains hidden or 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),] |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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\" |