View RasterLayer-list.R
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
# | |
# If I wrap a single RasterLayer in a list, I can extract it | |
# with .[[1]] but not with unlist(). | |
# | |
# This example just uses a single `RasterLayer` to make the point. | |
# The broader problem (for me) is that it seems to be precluding the | |
# possibility of using `purrr::map2()` to combine lists of RasterLayers | |
# in various ways. | |
# |
View example-calculations.R
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(units) | |
install_symbolic_unit("person") | |
install_conversion_constant("person", "death", const = -1) | |
options(digits = 8) | |
# For convenience, let's assume a population of 1 million people. | |
pop <- as_units(1e6, "person") | |
# Let's assume that the baseline annual all-cause mortality rate is | |
# about 1%, i.e., about 10,000 per million (per year). |
View BY2015-animal_waste-emission_factors-vs_BY2011.R
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
# | |
# BY2011 -> BY2015: emission factors for "animal waste" categories. | |
# | |
# Created by dholstius on 2019-11-21 for aguha. | |
# | |
# For the link between the two sets of categories, see (in Dropbox): | |
# | |
# - BY2015/Work/Crosswalks/Categories/BY2015_categories_geneaology.xlsx | |
# | |
# For more about the operations taking place in the code below, see (in R): |
View QA-BY2015-area_source-forecast.R
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
# | |
# BY2015-area_source-forecast-chart_annual_growth.R | |
# | |
# Created 2019-11-18 by dholstius | |
# | |
library(inventory) | |
library(ggtools) | |
# |
View BY2011-summarytree.R
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
#' | |
#' Summary Tree Tool | |
#' | |
#' Discover which categories --- or groups of categories --- emit the largest | |
#' share(s) of a particular pollutant. | |
#' | |
#' Version history: | |
#' | |
#' - Created 2015-12-01 by dholstius | |
#' - Last updated 2019-10-23 by dholstius |
View show138.R
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(inventory) | |
show138 <- function ( | |
DB_year, | |
category_id, | |
verbose = TRUE | |
) { | |
#' Define the preferred sorting order. | |
PONSCO_vars <- |
View example-DB_find_pollutants.R
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
# | |
# Turns out that #1350 is the DataBank ID for "Diesel PM". | |
# | |
# Here's an "old-school" way to figure that out. | |
# t0064 contains pollutant metadata. | |
# | |
library(Ingres) | |
help(t0064) # here's some Orange Binder material | |
view(t0064) # type "Diesel" in the search box (upper right) |
View BAAQMD-CCl4_emissions-PY_1997_2016.R
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
PY_CCl4_emission_data <- | |
PY(1997:2016) %>% | |
point_source_abated_emissions() %>% | |
filter_pollutants(list(CCl4 = 60)) | |
chart_data <- | |
PY_CCl4_emission_data %>% | |
mutate(fac_h1 = if_else(fac_id == 31, "Dow Chemical", "All Others")) %>% | |
annual_emissions_by(fac_h1) %>% | |
group_by(fac_h1) |
View UScensus2010-blk_data-reprex.R
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(UScensus2010) | |
library(UScensus2010tract) | |
library(UScensus2010blkgrp) | |
library(UScensus2010blk) | |
Cook_tracts <- UScensus2010::county(state = "Illinois", name = "Cook", level = "tract") | |
Cook_tracts@data[1:8, 1:8] | |
plot(Cook_tracts) | |
Cook_blkgrps <- UScensus2010::county(state = "Illinois", name = "Cook", level = "blkgrp") |
View rpivotTable-mySum.R
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(dplyr) | |
library(htmlwidgets) | |
library(rpivotTable) | |
mtcars %>% | |
rpivotTable(rows = "gear", | |
cols = c("cyl", "carb"), | |
vals = "hp", | |
# Step 1. Make this line accomplish the same thing as the default |
NewerOlder