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
# use MVB's foodweb to build a graphviz-compatible "dot" file | |
# this can then be used to generate a svg of the graph using: | |
# $ dot -Tsvg file.dot -o file.svg | |
# example usage: | |
# fw2dot("mrds","mrds.dot") | |
library(mvbutils) | |
fw2dot <- function(package.name,filename){ |
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
# example from ?mgcv::concurvity | |
library(mgcv) | |
## simulate data with concurvity... | |
set.seed(8);n<- 200 | |
f2 <- function(x) 0.2 * x^11 * (10 * (1 - x))^6 + 10 * | |
(10 * x)^3 * (1 - x)^10 | |
t <- sort(runif(n)) ## first covariate | |
## make covariate x a smooth function of t + noise... | |
x <- f2(t) + rnorm(n)*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
library(emoGG) | |
library(ggplot2) | |
# set the am variable to be different emoji | |
mtcars$am[mtcars$am==1] <- "1f697" | |
mtcars$am[mtcars$am==0] <- "1f68c" | |
# use am as the emoji aesthetic | |
ggplot(mtcars, aes(wt, mpg, emoji=am))+ geom_emoji() |
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
# 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
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
# 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
# watch all .Rmd files in a directory, if any change, knit them | |
library(knitr) | |
# use watch from Hadley's testthat package | |
library(testthat) | |
watchr<-function(path){ | |
# the path supplied here can just be something like "./" |