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
| #'------------------------------ | |
| #' | |
| #' Script to make sure everything works | |
| #' for you for the 2019-01-22 Geospatial | |
| #' Data Carpentry workshop at UMB | |
| #'------------------------------ | |
| # Make sure we have rnaturalearth installed | |
| # If you do, comment out the install.packages line | |
| #or just don't run it. |
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(sf) | |
| library(fasterize) | |
| library(spex) | |
| library(dplyr) | |
| library(purrr) | |
| library(ggplot2) | |
| library(lwgeom) | |
| test_set <- devtools::source_gist("c95701bd444cda3e342838fd9a090fb3", |
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
| structure(list(classification_id = c(82289537L, 82386012L, 84461998L, | |
| 85718077L, 91018956L, 102059723L, 102656990L, 103374144L, 105820504L, | |
| 108510525L, 113891667L, 120531542L, 133372372L, 133644897L, 134776350L | |
| ), geometry = structure(list(structure(list(structure(list(structure(c(314658.101094576, | |
| 314658.101094576, 314637.103677284, 314616.106259993, 314616.106259993, | |
| 314595.108842701, 314595.108842701, 314574.111425409, 314553.114008117, | |
| 314553.114008117, 314532.116590825, 314532.116590825, 314511.119173533, | |
| 314511.119173533, 314511.119173533, 314511.119173533, 314511.119173533, | |
| 314511.119173533, 314511.119173533, 314532.116590825, 314532.116590825, | |
| 314553.114008117, 314574.111425409, 314595.108842701, 314616.106259993, |
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
| tidy_residuals <- function(model){ | |
| UseMethod("tidy_residuals") | |
| } | |
| tidy_residuals.brmsfit <- function(model){ | |
| res <- residuals(model, summary=FALSE) | |
| props <- summary(model) | |
| nchains <- props$chains | |
| iter <- props$iter - props$warmup |
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
| brainGene <- structure(list(group = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, | |
| 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, | |
| 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, | |
| 3L, 3L, 3L, 3L, 3L, 3L), .Label = c("control", "schizo", "bipolar" | |
| ), class = "factor"), PLP1.expression = c(-0.02, -0.27, -0.11, | |
| 0.09, 0.25, -0.02, 0.48, -0.24, 0.06, 0.07, -0.3, -0.18, 0.04, | |
| -0.16, 0.25, -0.1, -0.31, -0.05, 0.11, -0.38, 0.23, -0.23, -0.28, | |
| -0.36, -0.22, -0.4, -0.19, -0.34, -0.29, -0.12, -0.34, -0.39, | |
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(tidyverse) | |
| library(emmeans) | |
| library(brms) | |
| library(tidybayes) | |
| warp.brms <- brm(breaks ~ wool * tension, data = warpbreaks) | |
| #get the adjusted means | |
| warp_em <- emmeans (warp.brms, ~ tension | wool) | |
| warp_em |
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(raster) | |
| #devtools::install_github("jebyrnes/hadsstr") | |
| library(hadsstr) #from jebyrnes/hadsstr | |
| library(ggplot2) | |
| library(sf) | |
| library(rnaturalearth) | |
| #get the world in the lambert projection | |
| countries_50_sf <- ne_download(scale = 50, category = 'cultural', type = 'countries', returnclass="sf") | |
| countries_lambert <- st_transform(oceans, 2154) |
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(ggplot2) | |
| #A glm from the glm helpfile | |
| counts <- c(18,17,15,20,10,20,25,13,12) | |
| outcome <- gl(3,1,9) | |
| treatment <- gl(3,3) | |
| print(d.AD <- data.frame(treatment, outcome, counts)) | |
| glm.D93 <- glm(counts ~ outcome + treatment, family = poisson()) | |
| #The old way... |
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(sf) | |
| library(rnaturalearth) | |
| library(rnaturalearthdata) | |
| library(ggplot2) | |
| oceans <- ne_download(type = "ocean", category = "physical", returnclass="sf") | |
| ocean_antarctic <- st_transform(oceans, 2154) | |
| ggplot(ocean_antarctic) + | |
| geom_sf(fill = "lightblue", color=NA) |
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
| #'---------------- | |
| #' Discrete time logistic growth model | |
| #' Using purrr and iwalk | |
| #'---------------- | |
| library(purrr) | |
| r <- 3.95237783423 | |
| n0 <- 0.3 |