diff --git a/Part1/02-data.Rmd b/Part1/02-data.Rmd index 6225c9e8..2edbbd0b 100644 --- a/Part1/02-data.Rmd +++ b/Part1/02-data.Rmd @@ -796,6 +796,7 @@ But also that they should have a basic understanding how could be done in base R Anecdote about using `dplyr` for very simple base R things, and deprecation/package stability in general. `dplyr` is stable now, but it wasn't. Be aware of that kind of thing when you use a new package. --> ``` + ### Missing Values "Missing" values are encoded in R as `NA`. `table()` has a `useNA` argument that affects whether `NA` values are counted. Use `is.na()` to return a logical value that identifies missing data. @@ -829,7 +830,7 @@ sort(table(pedons$texture), decreasing=TRUE) - GREATER than or equal to `>=` -- `%in%` Equivalent to `IN ()` in SQL; same logic as `match()` but returns a boolean, not integer +- `%in%` Equivalent to `IN ()` in SQL; same logic as `match()` but returns a logical, not integer - Example: `pedons$taxpartsize %in% c('loamy-skeletal', 'sandy-skeletal')` @@ -1011,23 +1012,10 @@ Tools for totally ordered indexed observations -- especially irregular time seri - [`tsibble`](https://github.com/tidyverts/tsibble) package provides a data structure for tidy temporal data and models. --> ``` -## Exercise 2: Generalized Horizons with Loafercreek - -Here we will introduce the concept of using regular expressions to apply "Generalized Horizon Labels" based on the field soil description horizon designations. - -This demonstrates one way of grouping horizon data for determining the Range in Characteristics of layers within a Soil Series or a SSURGO component. - -- [Generalized Horizon Labels with Loafercreek](http://ncss-tech.github.io/stats_for_soil_survey/exercises/genhz_homework.html) - -For the exercise during class, we will give you some time to read over the materials and apply the process to the sample `loafercreek` data. The code to apply the process to `loafercreek` is given. - -Then we ask that you apply a similar process to your own data, adjusting your generalized horizon patterns as needed for your local soils. - -This may take more time than we have during class itself, so you should follow up as needed with your mentor to complete the exercise. Chapter 3 Exploratory Data Analysis will get deeper into some of the topics that are referenced in the `loafercreek` code, such as summary statistics on grouped data. You will send a table and profile plots to your mentor when you are done. -This tutorial gives some further discussion of generalized horizon labels to order profiles based on horizon level properties. +## Exercise 2: O Horizon Thickness -- [Pair-Wise Distances by Generalized Horizon Labels tutorial](http://ncss-tech.github.io/AQP/aqp/genhz-distance-eval.html) +TODO ## `fetchNASIS()` data checks @@ -1297,7 +1285,7 @@ You can swap `landform_string` for: `landscape_string` (landscape), `hillslopepr #### Boolean Diagnostic Features in `fetchNASIS` -If diagnostic features are populated in the Pedon Diagnostic Features table in NASIS, then Boolean (`TRUE` or `FALSE`) fields are created for each diagnostic feature type found in the data brought in by `fetchNASIS`. +If diagnostic features are populated in the Pedon Diagnostic Features table in NASIS, then Boolean (`TRUE` or `FALSE`, or "logical") fields are created for each diagnostic feature type found in the data brought in by `fetchNASIS`. These fields can be used to model presence / absence of a diagnostic soil feature by extracting the site data from the `SoilProfileCollection` with `site()`. @@ -1353,7 +1341,7 @@ hist( ) ``` -Quick check: *What can you do with the boolean diagnostic feature data stored in the site table of a `fetchNASISSoilProfileCollection`?* +Quick check: *What can you do with the boolean diagnostic feature data stored in the site table of a `fetchNASIS()` SoilProfileCollection?* #### Diagnostic Feature Diagrams @@ -1542,6 +1530,24 @@ boxplot(d$doy, at = 26, horizontal = TRUE, add = TRUE, lty = 1, width = 1, col = ![](static-figures/CA792-soil-temperature-example.png) + +## Exercise 4: Generalized Horizons with Loafercreek + +Here we will introduce the concept of using regular expressions to apply "Generalized Horizon Labels" based on the field soil description horizon designations. + +This demonstrates one way of grouping horizon data for determining the Range in Characteristics of layers within a Soil Series or a SSURGO component. + +- [Generalized Horizon Labels with Loafercreek](http://ncss-tech.github.io/stats_for_soil_survey/exercises/genhz_homework.html) + +For the exercise during class, we will give you some time to read over the materials and apply the process to the sample `loafercreek` data. The code to apply the process to `loafercreek` is given. + +Then we ask that you apply a similar process to your own data, adjusting your generalized horizon patterns as needed for your local soils. + +This may take more time than we have during class itself, so you should follow up as needed with your mentor to complete the exercise. Chapter 3 Exploratory Data Analysis will get deeper into some of the topics that are referenced in the `loafercreek` code, such as summary statistics on grouped data. You will send a table and profile plots to your mentor when you are done. + +This tutorial gives some further discussion of generalized horizon labels to order profiles based on horizon level properties. + +- [Pair-Wise Distances by Generalized Horizon Labels tutorial](http://ncss-tech.github.io/AQP/aqp/genhz-distance-eval.html) + ```{r, echo=FALSE} rm(list = ls(all = TRUE)) ``` diff --git a/Part1/04-spatial.Rmd b/Part1/04-spatial.Rmd index c84b7129..095261ca 100644 --- a/Part1/04-spatial.Rmd +++ b/Part1/04-spatial.Rmd @@ -166,7 +166,7 @@ pedons <- fetchNASIS(from = 'pedons') - `longstddecimaldegrees` and `latstddecimaldegrees` variables contain WGS84 longitude and latitude in decimal degrees. This is the standard format for location information used in NASIS. -```{r, eval=FALSE} +```{eval=FALSE} # modify this code (replace ...) to create a subset pedons.sp <- aqp::subset(pedons, ...) ``` @@ -178,7 +178,7 @@ pedons.sp <- aqp::subset(pedons, !is.na(longstddecimaldegrees) & !is.na(latstdd 3. Create a `sf` data.frame from the site data in the SoilProfileCollection object `pedons.sp` using `aqp::site()`. Replace the `...` in the following code. Promoting a data.frame to sf POINT geometry requires that the X and Y columns be specified. -```{r, eval=FALSE} +```{eval=FALSE} pedon.locations <- sf::st_as_sf( ..., coords = c('longstddecimaldegrees', 'latstddecimaldegrees'), @@ -197,7 +197,7 @@ pedon.locations <- sf::st_as_sf( 4. View your `sf` object `pedon.locations` interactively with `mapview::mapview()`, and change the `map.types` argument to `'Esri.WorldImagery'`. Use the `pedon.locations` column named `site_id` for the `label` argument. -```{r} +``` # plot an interactive map mapview(pedon.locations, legend = FALSE, @@ -215,7 +215,7 @@ mapview(pedon.locations, 5. Create a subset `sf` data.frame with only the following "site data" columns: `pedlabsampnum`, `upedonid`, `taxonname`, `hillslopeprof`, `elev_field`, `slope_field`, `aspect_field`, `plantassocnm`, `bedrckdepth`, `bedrckkind`, `pmkind`, `pmorigin`. Select the target columns with `dplyr::select()` (or another method) by replacing the `...` in the following code. -```{r, eval=FALSE} +``` pedon.locations_sub <- dplyr::select(pedon.locations, ...) # see also base::subset(x, select=...) ``` @@ -229,7 +229,8 @@ sf::st_write(pedon.locations_sub, "./NASIS-pedons.shp") 7. Send a screenshot of your interactive map, and your R script, to your mentor. -For an example of exporting data to shapefile with the `sp` package, see this tutorial: [**Export Pedons to Shapefile with `sp`**](http://ncss-tech.github.io/AQP/soilDB/export-points-from-NASIS.html).