Introduction

This documentation describes how tables from the New York State Department of Environmental Conservation's (NYSDEC's) database are prepared for informing assessments using the stayCALM R-package. Some of this work will not be necessary once the database is finalized. There will still be some amount of data preparation, but it should not be as extensive.

Preprocessing

Prepare the R Environment

Load the necessary R packages into the global environment.

library(tidyr)
library(readxl)
library(stayCALM)

Upload and Prepare CALM Logic Files.

These files should be finalized and added to the the Assessment database.

Establish the file path to the Excel workbook created by Keleigh Reynolds and Sarah Rickard to tabularize NYSDEC's water quality standards.

calm_logic.path <- file.path(
  "C:",
  "Users",
  "zmsmith.000",
  "New York State Office of Information Technology Services",
  "BWAM - Automation of Assessment",
  "Logic_CALM_Automation_v4.xlsx"
)

This sheet contains NYSDEC's waterbody classes and the associated best use(s).

org.df <- read_xlsx(calm_logic.path,
                    sheet = "class_use")

Expand the collapsed use and class cells into multiple rows.

class_use <- org.df %>% 
  separate_rows(use, sep = "; ") %>% 
  separate_rows(class, sep = "; ")

Assign the appropriate trout variants to the waterbody class and unnest them to ensure that each a single class variant is represented in each row.

class_use$class <- assign_trout_class(class_use$trout_class, class_use$class)
class_use <- unnest(class_use, class)

Export NYSDEC Class/Use Table

With the usethis package, the master class/use data is exported as a .rda file making it easily accessible during the development and testing of the stayCALM package.

usethis::use_data(class_use, overwrite = TRUE)


BWAM/stayCALM documentation built on May 21, 2020, 3:24 p.m.