This report is automatically generated with the R package knitr (version 1.40) .

## LOAD PACKAGES USED IN SCRIPTS ##
source("R Functions/functions_QA data.R")


# LOAD DATA MASTER #
AqMaster <- readxl::read_excel('Reeval_Impl_Goals_Linkage_Analysis/Data/Aqueous/2a_AqMaster_GISprepped.xlsx', sheet=1, guess_max = 30000)
nrow(AqMaster)
## [1] 73219
# LOAD WORKBOOK OF SITES THAT HAVE TMDL & DELTA SUBREGION DESIGNATIONS #
demarcatedSites <- readxl::read_excel('Reeval_Impl_Goals_Linkage_Analysis/Data/Aqueous/3b_AqSites_DemarcFromGIS.xlsx', sheet=1) %>%
  select(uniqName, TMDL, Subarea)

# JOIN AqMaster with TMDL & DeltaSubregion COLUMNS 
AqMaster <- AqMaster %>%
  mutate(uniqName = paste(StationName, round(TargetLatitude,4), round(TargetLongitude,4))) %>% # needs to be the same code used in Script2 ScopeDaSites %>% mutate(uniqName=)
  left_join(., demarcatedSites, by='uniqName') %>% # adds TMDL & Subarea columns
  select(-uniqName) %>%  #Put TMDL column in first position
  select(TMDL, Subarea, everything())
nrow(AqMaster)
## [1] 73219
# Fix Subareas that GIS pulled into wrong Subarea using SpatialJoin and 100m extension (StationName identified by looking at GIS map)
AqMaster <- AqMaster %>%
  mutate(Subarea = ifelse(grepl("San Joaquin River near Burns Canal", StationName, ignore.case=T),
                          "San Joaquin River", Subarea),
         #rename subareas to match nomenclature in Staff Report
         Subarea = recode(Subarea,
                          "Mokelumne River" = "Moke/Cos Rivers",        # Fix subarea names
                          "Yolo Bypass-North" = "YB-North",
                          "Yolo Bypass-South" = "YB-South"))


# SAVE AqMaster WITH TMDL & DELTA SUBREGION DESIGNATIONS #
writexl::write_xlsx(AqMaster, path='Reeval_Impl_Goals_Linkage_Analysis/Data/Aqueous/3a_AqMaster_GISdemarcated.xlsx')

The R session information (including the OS info, R version and all packages used):

    sessionInfo()
## R version 4.2.2 (2022-10-31 ucrt)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows 10 x64 (build 22621)
## 
## Matrix products: default
## 
## locale:
## [1] LC_COLLATE=English_United States.utf8  LC_CTYPE=C                            
## [3] LC_MONETARY=English_United States.utf8 LC_NUMERIC=C                          
## [5] LC_TIME=English_United States.utf8    
## system code page: 65001
## 
## attached base packages:
## [1] grid      stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
##  [1] lubridate_1.8.0    plotly_4.10.0      readxl_1.4.1       actuar_3.3-0      
##  [5] NADA_1.6-1.1       forcats_0.5.2      stringr_1.4.1      dplyr_1.0.9       
##  [9] purrr_0.3.4        readr_2.1.2        tidyr_1.2.0        tibble_3.1.8      
## [13] ggplot2_3.3.6      tidyverse_1.3.2    fitdistrplus_1.1-8 survival_3.4-0    
## [17] MASS_7.3-58.1     
## 
## loaded via a namespace (and not attached):
##  [1] lattice_0.20-45     assertthat_0.2.1    digest_0.6.29       utf8_1.2.2         
##  [5] R6_2.5.1            cellranger_1.1.0    backports_1.4.1     reprex_2.0.2       
##  [9] evaluate_0.16       highr_0.9           httr_1.4.4          pillar_1.8.1       
## [13] rlang_1.0.5         lazyeval_0.2.2      googlesheets4_1.0.1 data.table_1.14.2  
## [17] rstudioapi_0.14     Matrix_1.5-1        rmarkdown_2.16      splines_4.2.2      
## [21] googledrive_2.0.0   htmlwidgets_1.5.4   munsell_0.5.0       broom_1.0.1        
## [25] compiler_4.2.2      modelr_0.1.9        xfun_0.32           pkgconfig_2.0.3    
## [29] htmltools_0.5.3     tidyselect_1.1.2    viridisLite_0.4.1   fansi_1.0.3        
## [33] crayon_1.5.1        tzdb_0.3.0          dbplyr_2.2.1        withr_2.5.0        
## [37] jsonlite_1.8.0      gtable_0.3.1        lifecycle_1.0.1     DBI_1.1.3          
## [41] magrittr_2.0.3      scales_1.2.1        writexl_1.4.0       cli_3.3.0          
## [45] stringi_1.7.8       fs_1.5.2            xml2_1.3.3          ellipsis_0.3.2     
## [49] generics_0.1.3      vctrs_0.4.1         expint_0.1-7        tools_4.2.2        
## [53] glue_1.6.2          hms_1.1.2           fastmap_1.1.0       yaml_2.3.5         
## [57] colorspace_2.0-3    gargle_1.2.0        rvest_1.0.3         knitr_1.40         
## [61] haven_2.5.1
    Sys.time()
## [1] "2023-12-29 12:06:41 PST"