library(tidyverse)
library(lubridate)
library(broom)
library(scales)
library(gganimate)
# Load and clean data
# This data comes from Dark Sky's API
weather_provo_raw <- read_csv("https://andhs.co/provoweather")
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
# https://github.com/dblodgett-usgs/nhdplusTools | |
library(nhdplusTools) | |
# https://github.com/USGS-R/HUCAgg | |
library(HUCAgg) | |
library(sf) | |
library(dplyr) | |
library(snow) | |
wbd_gdb <- "WBD_National_GDB.gdb" |
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(USAboundaries) | |
library(sf) | |
library(dplyr) | |
library(elevatr) | |
library(raster) | |
# Get map of lower 48 states | |
usa_l48 <- us_boundaries() %>% | |
filter(state_abbr != "HI" & | |
state_abbr != "AK" & |
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
# Code from Richard McElreath's book, chapter 6 | |
sppnames <- c( "afarensis","africanus","habilis","boisei", | |
"rudolfensis","ergaster","sapiens") | |
brainvolcc <- c( 438 , 452 , 612, 521, 752, 871, 1350 ) | |
masskg <- c( 37.0 , 35.5 , 34.5 , 41.5 , 55.5 , 61.0 , 53.5 ) | |
d <- data.frame( species=sppnames , brain=brainvolcc , mass=masskg ) | |
## R code 6.2 | |
m6.1 <- lm( brain ~ mass , data=d ) |
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
# | |
# Compare lmer and inla for LMM | |
# largely taken from Spatial and spatio-temporal bayesian models with R-INLA (Blangiardo & Cameletti, 2015), section 5.4.2 | |
# | |
m <- 10000 # N obs | |
set.seed(1234) | |
x <- rnorm(m) | |
group <- sample(seq(1, 100), size = m, replace = TRUE) |
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
--- | |
title: "World maps" | |
output: | |
html_document: | |
df_print: paged | |
--- | |
```{r echo = FALSE, message = FALSE} | |
library(tidyverse) | |
library(sf) |
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
### Title: Back to basics: High quality plots using base R graphics | |
### An interactive tutorial for the Davis R Users Group meeting on April 24, 2015 | |
### | |
### Date created: 20150418 | |
### Last updated: 20150423 | |
### | |
### Author: Michael Koontz | |
### Email: [email protected] | |
### Twitter: @michaeljkoontz | |
### |
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
### My favourite ggplot2 themes, always accessible ### | |
## just source this gist from any project ## | |
##################################################################################### | |
# Noam's default ggplot2 styling ##### | |
# Source: https://github.com/noamross/noamtools/blob/master/R/theme_nr.R | |
theme_nr <-theme(text=element_text(family="Helvetica", size=14), | |
panel.grid.major.x=element_blank(), |
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
## from: https://logfc.wordpress.com/2017/03/15/adding-figure-labels-a-b-c-in-the-top-left-corner-of-the-plotting-region/ | |
fig_label <- function(text, region="figure", pos="topleft", cex=NULL, ...) { | |
region <- match.arg(region, c("figure", "plot", "device")) | |
pos <- match.arg(pos, c("topleft", "top", "topright", | |
"left", "center", "right", | |
"bottomleft", "bottom", "bottomright")) | |
if(region %in% c("figure", "device")) { |
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(patchwork) | |
library(ggplot2) | |
library(purrr) | |
library(dplyr) | |
library(glue) | |
map( | |
5:8, | |
~iris %>% | |
filter(Petal.Length < .x) %>% | |
ggplot() + |
NewerOlder