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")


 ## RUN 1st & 2nd SCRIPTS TO LOAD & MERGE CEDEN FORMATTED DATA ##
source('Reeval_Impl_Goals_Linkage_Analysis/Data/Aqueous/AmericanRiver_format-to-ceden.R')
## 'MDL' column converted to numeric format
## 'RL' column converted to numeric format
source('Reeval_Impl_Goals_Linkage_Analysis/Data/Aqueous/App_L_MeHg_format-to-ceden.R')
## 'Result' column converted to numeric format
## 'Result' made blank when 'ResultQualCode' = 'ND'
## 'MDL' column converted to numeric format
sort(names(AmericanRiver_new)); nrow(AmericanRiver_new)
##  [1] "Analyte"            "BatchComments"      "BatchVerification"  "CitationCode"      
##  [5] "CollectionComments" "ComplianceCode"     "CoordSystem"        "LabBatch"          
##  [9] "LabSampleID"        "MatrixName"         "MDL"                "MethodName"        
## [13] "Project"            "QACode"             "Result"             "ResultQualCode"    
## [17] "ResultsComments"    "RL"                 "SampleComments"     "SampleDate"        
## [21] "SampleDateTime"     "SampleID"           "SampleTime"         "SampleTypeCode"    
## [25] "SourceID"           "SourceRow"          "StationCode"        "StationName"       
## [29] "TargetLatitude"     "TargetLongitude"    "Unit"               "WBT"
## [1] 1366
sort(names(App_L_MeHg_new)); nrow(App_L_MeHg_new)
##  [1] "Analyte"            "BatchComments"      "BatchVerification"  "CitationCode"      
##  [5] "CollectionComments" "ComplianceCode"     "CoordSystem"        "LabBatch"          
##  [9] "LabSampleID"        "MatrixName"         "MDL"                "MethodName"        
## [13] "Project"            "QACode"             "Result"             "ResultQualCode"    
## [17] "ResultsComments"    "RL"                 "SampleComments"     "SampleDate"        
## [21] "SampleDateTime"     "SampleID"           "SampleTime"         "SampleTypeCode"    
## [25] "SourceID"           "SourceRow"          "StationCode"        "StationName"       
## [29] "TargetLatitude"     "TargetLongitude"    "Unit"               "WBT"
## [1] 358
AqMaster <- rbind(AmericanRiver_new, App_L_MeHg_new)
rm(list=setdiff(ls(), 'AqMaster')) #removes all objects except 'AqMaster'


 ## RUN 3rd SCRIPT TO LOAD & MERGE CEDEN FORMATTED DATA ##
source('Reeval_Impl_Goals_Linkage_Analysis/Data/Aqueous/App_L_THg_format-to-ceden.R')
## 'Result' column converted to numeric format
## 'MDL' column converted to numeric format
sort(names(AqMaster)); nrow(AqMaster)
##  [1] "Analyte"            "BatchComments"      "BatchVerification"  "CitationCode"      
##  [5] "CollectionComments" "ComplianceCode"     "CoordSystem"        "LabBatch"          
##  [9] "LabSampleID"        "MatrixName"         "MDL"                "MethodName"        
## [13] "Project"            "QACode"             "Result"             "ResultQualCode"    
## [17] "ResultsComments"    "RL"                 "SampleComments"     "SampleDate"        
## [21] "SampleDateTime"     "SampleID"           "SampleTime"         "SampleTypeCode"    
## [25] "SourceID"           "SourceRow"          "StationCode"        "StationName"       
## [29] "TargetLatitude"     "TargetLongitude"    "Unit"               "WBT"
## [1] 1724
sort(names(App_L_THg_new)); nrow(App_L_THg_new)
##  [1] "Analyte"            "BatchComments"      "BatchVerification"  "CitationCode"      
##  [5] "CollectionComments" "ComplianceCode"     "CoordSystem"        "LabBatch"          
##  [9] "LabSampleID"        "MatrixName"         "MDL"                "MethodName"        
## [13] "Project"            "QACode"             "Result"             "ResultQualCode"    
## [17] "ResultsComments"    "RL"                 "SampleComments"     "SampleDate"        
## [21] "SampleDateTime"     "SampleID"           "SampleTime"         "SampleTypeCode"    
## [25] "SourceID"           "SourceRow"          "StationCode"        "StationName"       
## [29] "TargetLatitude"     "TargetLongitude"    "Unit"               "WBT"
## [1] 1219
AqMaster <- rbind(AqMaster, App_L_THg_new)
rm(list=setdiff(ls(), 'AqMaster')) #removes all objects except 'AqMaster'


 ## RUN 4th SCRIPT TO LOAD & MERGE CEDEN FORMATTED DATA ##
source('Reeval_Impl_Goals_Linkage_Analysis/Data/Aqueous/CALFED2003-1a_format_to_ceden.R')
## 'Result' column should be numeric but some cells contain broken, 0.022U, 0.014U, 0.013U, 0.007U, nd, leak in State Water Project lift Canal, reservoir dry, <1.0, <1, and <2.0.
## ACTIONS TAKEN:
## Values with 'U' or '<' were recorded in MDL column, 'ND' in ResultQualCode column, and 'NA' in Result column.
## Result with ND (only @ Pospect Slough for DMMHg on 7/19/00), 'ND' recorded in ResultQualCode column 'NA' in Result column, and 0.022 in MDL from data_MMHg_QA.xlsx
## Results with 'broken' and 'reservoir dry' were replaced with 'NA' in Result column.
sort(names(AqMaster)); nrow(AqMaster)
##  [1] "Analyte"            "BatchComments"      "BatchVerification"  "CitationCode"      
##  [5] "CollectionComments" "ComplianceCode"     "CoordSystem"        "LabBatch"          
##  [9] "LabSampleID"        "MatrixName"         "MDL"                "MethodName"        
## [13] "Project"            "QACode"             "Result"             "ResultQualCode"    
## [17] "ResultsComments"    "RL"                 "SampleComments"     "SampleDate"        
## [21] "SampleDateTime"     "SampleID"           "SampleTime"         "SampleTypeCode"    
## [25] "SourceID"           "SourceRow"          "StationCode"        "StationName"       
## [29] "TargetLatitude"     "TargetLongitude"    "Unit"               "WBT"
## [1] 2943
sort(names(CALFED2003_1a_mercury)); nrow(CALFED2003_1a_mercury)
##  [1] "Analyte"            "BatchComments"      "BatchVerification"  "CitationCode"      
##  [5] "CollectionComments" "ComplianceCode"     "CoordSystem"        "LabBatch"          
##  [9] "LabSampleID"        "MatrixName"         "MDL"                "MethodName"        
## [13] "Project"            "QACode"             "Result"             "ResultQualCode"    
## [17] "ResultsComments"    "RL"                 "SampleComments"     "SampleDate"        
## [21] "SampleDateTime"     "SampleID"           "SampleTime"         "SampleTypeCode"    
## [25] "SourceID"           "SourceRow"          "StationCode"        "StationName"       
## [29] "TargetLatitude"     "TargetLongitude"    "Unit"               "WBT"
## [1] 565
AqMaster <- rbind(AqMaster, CALFED2003_1a_mercury)
rm(list=setdiff(ls(), 'AqMaster')) #removes all objects except 'AqMaster'


 ## RUN 5th SCRIPT TO LOAD & MERGE CEDEN FORMATTED DATA ##
source('Reeval_Impl_Goals_Linkage_Analysis/Data/Aqueous/CEDENAqSed_format-to-ceden.R')
sort(names(AqMaster)); nrow(AqMaster)
##  [1] "Analyte"            "BatchComments"      "BatchVerification"  "CitationCode"      
##  [5] "CollectionComments" "ComplianceCode"     "CoordSystem"        "LabBatch"          
##  [9] "LabSampleID"        "MatrixName"         "MDL"                "MethodName"        
## [13] "Project"            "QACode"             "Result"             "ResultQualCode"    
## [17] "ResultsComments"    "RL"                 "SampleComments"     "SampleDate"        
## [21] "SampleDateTime"     "SampleID"           "SampleTime"         "SampleTypeCode"    
## [25] "SourceID"           "SourceRow"          "StationCode"        "StationName"       
## [29] "TargetLatitude"     "TargetLongitude"    "Unit"               "WBT"
## [1] 3508
sort(names(CEDENAqSed_new)); nrow(CEDENAqSed_new)
##  [1] "Analyte"            "BatchComments"      "BatchVerification"  "CitationCode"      
##  [5] "CollectionComments" "ComplianceCode"     "CoordSystem"        "LabBatch"          
##  [9] "LabSampleID"        "MatrixName"         "MDL"                "MethodName"        
## [13] "Project"            "QACode"             "Result"             "ResultQualCode"    
## [17] "ResultsComments"    "RL"                 "SampleComments"     "SampleDate"        
## [21] "SampleDateTime"     "SampleID"           "SampleTime"         "SampleTypeCode"    
## [25] "SourceID"           "SourceRow"          "StationCode"        "StationName"       
## [29] "TargetLatitude"     "TargetLongitude"    "Unit"               "WBT"
## [1] 8852
AqMaster <- rbind(AqMaster, CEDENAqSed_new)
rm(list=setdiff(ls(), 'AqMaster')) #removes all objects except 'AqMaster'


  ## RUN 6th SCRIPT TO LOAD & MERGE CEDEN FORMATTED DATA ##
source('Reeval_Impl_Goals_Linkage_Analysis/Data/Aqueous/DeltaSED_format-to-ceden.R')
sort(names(AqMaster)); nrow(AqMaster)
##  [1] "Analyte"            "BatchComments"      "BatchVerification"  "CitationCode"      
##  [5] "CollectionComments" "ComplianceCode"     "CoordSystem"        "LabBatch"          
##  [9] "LabSampleID"        "MatrixName"         "MDL"                "MethodName"        
## [13] "Project"            "QACode"             "Result"             "ResultQualCode"    
## [17] "ResultsComments"    "RL"                 "SampleComments"     "SampleDate"        
## [21] "SampleDateTime"     "SampleID"           "SampleTime"         "SampleTypeCode"    
## [25] "SourceID"           "SourceRow"          "StationCode"        "StationName"       
## [29] "TargetLatitude"     "TargetLongitude"    "Unit"               "WBT"
## [1] 12360
sort(names(DeltaSED_new)); nrow(DeltaSED_new)
##  [1] "Analyte"            "BatchComments"      "BatchVerification"  "CitationCode"      
##  [5] "CollectionComments" "ComplianceCode"     "CoordSystem"        "LabBatch"          
##  [9] "LabSampleID"        "MatrixName"         "MDL"                "MethodName"        
## [13] "Project"            "QACode"             "Result"             "ResultQualCode"    
## [17] "ResultsComments"    "RL"                 "SampleComments"     "SampleDate"        
## [21] "SampleDateTime"     "SampleID"           "SampleTime"         "SampleTypeCode"    
## [25] "SourceID"           "SourceRow"          "StationCode"        "StationName"       
## [29] "TargetLatitude"     "TargetLongitude"    "Unit"               "WBT"
## [1] 848
AqMaster <- rbind(AqMaster, DeltaSED_new)
rm(list=setdiff(ls(), 'AqMaster')) #removes all objects except 'AqMaster'


  ## RUN 7th SCRIPT TO LOAD & MERGE CEDEN FORMATTED DATA ##
source('Reeval_Impl_Goals_Linkage_Analysis/Data/Aqueous/DRMP_format-to-ceden.R')
## 'Result' column is in numeric format
## 'MDL' column is in numeric format
## 'RL' column is in numeric format
sort(names(AqMaster)); nrow(AqMaster)
##  [1] "Analyte"            "BatchComments"      "BatchVerification"  "CitationCode"      
##  [5] "CollectionComments" "ComplianceCode"     "CoordSystem"        "LabBatch"          
##  [9] "LabSampleID"        "MatrixName"         "MDL"                "MethodName"        
## [13] "Project"            "QACode"             "Result"             "ResultQualCode"    
## [17] "ResultsComments"    "RL"                 "SampleComments"     "SampleDate"        
## [21] "SampleDateTime"     "SampleID"           "SampleTime"         "SampleTypeCode"    
## [25] "SourceID"           "SourceRow"          "StationCode"        "StationName"       
## [29] "TargetLatitude"     "TargetLongitude"    "Unit"               "WBT"
## [1] 13208
sort(names(DRMP_new)); nrow(DRMP_new)
##  [1] "Analyte"            "BatchComments"      "BatchVerification"  "CitationCode"      
##  [5] "CollectionComments" "ComplianceCode"     "CoordSystem"        "LabBatch"          
##  [9] "LabSampleID"        "MatrixName"         "MDL"                "MethodName"        
## [13] "Project"            "QACode"             "Result"             "ResultQualCode"    
## [17] "ResultsComments"    "RL"                 "SampleComments"     "SampleDate"        
## [21] "SampleDateTime"     "SampleID"           "SampleTime"         "SampleTypeCode"    
## [25] "SourceID"           "SourceRow"          "StationCode"        "StationName"       
## [29] "TargetLatitude"     "TargetLongitude"    "Unit"               "WBT"
## [1] 1006
AqMaster <- rbind(AqMaster, DRMP_new)
rm(list=setdiff(ls(), 'AqMaster')) #removes all objects except 'AqMaster'


  ## RUN 8th SCRIPT TO LOAD & MERGE CEDEN FORMATTED DATA ##
source('Reeval_Impl_Goals_Linkage_Analysis/Data/Aqueous/DWR_format-to-ceden.R')
## 'Result' column should be numeric but some cells contain < R.L..
##  '< R.L' changed to NA and DNQ added to ResultQualCode Column.
## 'MDL' column is in numeric format'RL' column is in numeric format
sort(names(AqMaster)); nrow(AqMaster)
##  [1] "Analyte"            "BatchComments"      "BatchVerification"  "CitationCode"      
##  [5] "CollectionComments" "ComplianceCode"     "CoordSystem"        "LabBatch"          
##  [9] "LabSampleID"        "MatrixName"         "MDL"                "MethodName"        
## [13] "Project"            "QACode"             "Result"             "ResultQualCode"    
## [17] "ResultsComments"    "RL"                 "SampleComments"     "SampleDate"        
## [21] "SampleDateTime"     "SampleID"           "SampleTime"         "SampleTypeCode"    
## [25] "SourceID"           "SourceRow"          "StationCode"        "StationName"       
## [29] "TargetLatitude"     "TargetLongitude"    "Unit"               "WBT"
## [1] 14214
sort(names(DWR_new)); nrow(DWR_new)
##  [1] "Analyte"            "BatchComments"      "BatchVerification"  "CitationCode"      
##  [5] "CollectionComments" "ComplianceCode"     "CoordSystem"        "LabBatch"          
##  [9] "LabSampleID"        "MatrixName"         "MDL"                "MethodName"        
## [13] "Project"            "QACode"             "Result"             "ResultQualCode"    
## [17] "ResultsComments"    "RL"                 "SampleComments"     "SampleDate"        
## [21] "SampleDateTime"     "SampleID"           "SampleTime"         "SampleTypeCode"    
## [25] "SourceID"           "SourceRow"          "StationCode"        "StationName"       
## [29] "TargetLatitude"     "TargetLongitude"    "Unit"               "WBT"
## [1] 2974
AqMaster <- rbind(AqMaster, DWR_new)
rm(list=setdiff(ls(), 'AqMaster')) #removes all objects except 'AqMaster'


  ## RUN 9th SCRIPT TO LOAD & MERGE CEDEN FORMATTED DATA ##
source('Reeval_Impl_Goals_Linkage_Analysis/Data/Aqueous/DWRMeHg_format-to-ceden.R')
## 'Result' column should be numeric but some cells contain < R.L..
##  '<RL in 'Result, altered to standardize to 'ND'.
## 'MDL' column is in numeric format'RL' column is in numeric format
sort(names(AqMaster)); nrow(AqMaster)
##  [1] "Analyte"            "BatchComments"      "BatchVerification"  "CitationCode"      
##  [5] "CollectionComments" "ComplianceCode"     "CoordSystem"        "LabBatch"          
##  [9] "LabSampleID"        "MatrixName"         "MDL"                "MethodName"        
## [13] "Project"            "QACode"             "Result"             "ResultQualCode"    
## [17] "ResultsComments"    "RL"                 "SampleComments"     "SampleDate"        
## [21] "SampleDateTime"     "SampleID"           "SampleTime"         "SampleTypeCode"    
## [25] "SourceID"           "SourceRow"          "StationCode"        "StationName"       
## [29] "TargetLatitude"     "TargetLongitude"    "Unit"               "WBT"
## [1] 17188
sort(names(DWRMeHg_new)); nrow(DWRMeHg_new)
##  [1] "Analyte"            "BatchComments"      "BatchVerification"  "CitationCode"      
##  [5] "CollectionComments" "ComplianceCode"     "CoordSystem"        "LabBatch"          
##  [9] "LabSampleID"        "MatrixName"         "MDL"                "MethodName"        
## [13] "Project"            "QACode"             "Result"             "ResultQualCode"    
## [17] "ResultsComments"    "RL"                 "SampleComments"     "SampleDate"        
## [21] "SampleDateTime"     "SampleID"           "SampleTime"         "SampleTypeCode"    
## [25] "SourceID"           "SourceRow"          "StationCode"        "StationName"       
## [29] "TargetLatitude"     "TargetLongitude"    "Unit"               "WBT"
## [1] 675
AqMaster <- rbind(AqMaster, DWRMeHg_new)
rm(list=setdiff(ls(), 'AqMaster')) #removes all objects except 'AqMaster'


  ## RUN 10th SCRIPT TO LOAD & MERGE CEDEN FORMATTED DATA ##
source('Reeval_Impl_Goals_Linkage_Analysis/Data/Aqueous/R5AQ_format-to-ceden.R')
## 'Result' column should be numeric but some cells contain <MDL.
## ACTIONS TAKEN:
## Numeric MDL value from SampleComments column was placed in MDL column when MDL column = '-88'.
## Result value of '<MDL' replaced with 'NA'.
sort(names(AqMaster)); nrow(AqMaster)
##  [1] "Analyte"            "BatchComments"      "BatchVerification"  "CitationCode"      
##  [5] "CollectionComments" "ComplianceCode"     "CoordSystem"        "LabBatch"          
##  [9] "LabSampleID"        "MatrixName"         "MDL"                "MethodName"        
## [13] "Project"            "QACode"             "Result"             "ResultQualCode"    
## [17] "ResultsComments"    "RL"                 "SampleComments"     "SampleDate"        
## [21] "SampleDateTime"     "SampleID"           "SampleTime"         "SampleTypeCode"    
## [25] "SourceID"           "SourceRow"          "StationCode"        "StationName"       
## [29] "TargetLatitude"     "TargetLongitude"    "Unit"               "WBT"
## [1] 17863
sort(names(R5AQ_new)); nrow(R5AQ_new)
##  [1] "Analyte"            "BatchComments"      "BatchVerification"  "CitationCode"      
##  [5] "CollectionComments" "ComplianceCode"     "CoordSystem"        "LabBatch"          
##  [9] "LabSampleID"        "MatrixName"         "MDL"                "MethodName"        
## [13] "Project"            "QACode"             "Result"             "ResultQualCode"    
## [17] "ResultsComments"    "RL"                 "SampleComments"     "SampleDate"        
## [21] "SampleDateTime"     "SampleID"           "SampleTime"         "SampleTypeCode"    
## [25] "SourceID"           "SourceRow"          "StationCode"        "StationName"       
## [29] "TargetLatitude"     "TargetLongitude"    "Unit"               "WBT"
## [1] 5662
AqMaster <- rbind(AqMaster, R5AQ_new)
rm(list=setdiff(ls(), 'AqMaster')) #removes all objects except 'AqMaster'


 ## RUN 11th SCRIPT TO LOAD & MERGE CEDEN FORMATTED DATA ##
source('Reeval_Impl_Goals_Linkage_Analysis/Data/Aqueous/R5SED_format-to-ceden.R')
## 'Result' column should be numeric but some cells contain <MDL.
## ACTIONS TAKEN:
## MDL and RL values exist in designated columns so Result of '<MDL' replaced with 'NA'.
sort(names(AqMaster)); nrow(AqMaster)
##  [1] "Analyte"            "BatchComments"      "BatchVerification"  "CitationCode"      
##  [5] "CollectionComments" "ComplianceCode"     "CoordSystem"        "LabBatch"          
##  [9] "LabSampleID"        "MatrixName"         "MDL"                "MethodName"        
## [13] "Project"            "QACode"             "Result"             "ResultQualCode"    
## [17] "ResultsComments"    "RL"                 "SampleComments"     "SampleDate"        
## [21] "SampleDateTime"     "SampleID"           "SampleTime"         "SampleTypeCode"    
## [25] "SourceID"           "SourceRow"          "StationCode"        "StationName"       
## [29] "TargetLatitude"     "TargetLongitude"    "Unit"               "WBT"
## [1] 23525
sort(names(R5SED_new)); nrow(R5SED_new)
##  [1] "Analyte"            "BatchComments"      "BatchVerification"  "CitationCode"      
##  [5] "CollectionComments" "ComplianceCode"     "CoordSystem"        "LabBatch"          
##  [9] "LabSampleID"        "MatrixName"         "MDL"                "MethodName"        
## [13] "Project"            "QACode"             "Result"             "ResultQualCode"    
## [17] "ResultsComments"    "RL"                 "SampleComments"     "SampleDate"        
## [21] "SampleDateTime"     "SampleID"           "SampleTime"         "SampleTypeCode"    
## [25] "SourceID"           "SourceRow"          "StationCode"        "StationName"       
## [29] "TargetLatitude"     "TargetLongitude"    "Unit"               "WBT"
## [1] 303
AqMaster <- rbind(AqMaster, R5SED_new)
rm(list=setdiff(ls(), 'AqMaster')) #removes all objects except 'AqMaster'


 ## RUN 12th SCRIPT TO LOAD & MERGE CEDEN FORMATTED DATA ##
source('Reeval_Impl_Goals_Linkage_Analysis/Data/Aqueous/SNIP_format-to-ceden.R')
## 'Result' column converted to numeric format
## 'MDL' column converted to numeric format
## 'RL' column converted to numeric format
## Warning: 2 failed to parse.
sort(names(AqMaster)); nrow(AqMaster)
##  [1] "Analyte"            "BatchComments"      "BatchVerification"  "CitationCode"      
##  [5] "CollectionComments" "ComplianceCode"     "CoordSystem"        "LabBatch"          
##  [9] "LabSampleID"        "MatrixName"         "MDL"                "MethodName"        
## [13] "Project"            "QACode"             "Result"             "ResultQualCode"    
## [17] "ResultsComments"    "RL"                 "SampleComments"     "SampleDate"        
## [21] "SampleDateTime"     "SampleID"           "SampleTime"         "SampleTypeCode"    
## [25] "SourceID"           "SourceRow"          "StationCode"        "StationName"       
## [29] "TargetLatitude"     "TargetLongitude"    "Unit"               "WBT"
## [1] 23828
sort(names(SNIP_new)); nrow(SNIP_new)
##  [1] "Analyte"            "BatchComments"      "BatchVerification"  "CitationCode"      
##  [5] "CollectionComments" "ComplianceCode"     "CoordSystem"        "LabBatch"          
##  [9] "LabSampleID"        "MatrixName"         "MDL"                "MethodName"        
## [13] "Project"            "QACode"             "Result"             "ResultQualCode"    
## [17] "ResultsComments"    "RL"                 "SampleComments"     "SampleDate"        
## [21] "SampleDateTime"     "SampleID"           "SampleTime"         "SampleTypeCode"    
## [25] "SourceID"           "SourceRow"          "StationCode"        "StationName"       
## [29] "TargetLatitude"     "TargetLongitude"    "Unit"               "WBT"
## [1] 22016
AqMaster <- rbind(AqMaster, SNIP_new)
rm(list=setdiff(ls(), 'AqMaster')) #removes all objects except 'AqMaster'


 ## RUN 13th SCRIPT TO LOAD & MERGE CEDEN FORMATTED DATA ##
source('Reeval_Impl_Goals_Linkage_Analysis/Data/Aqueous/USGS_format-to-ceden.R')
## 'Result' column should be numeric but some cells contain <0.02, <0.0004, NA, ND, <3.1, <4.6, <49, <9.3, <24, <120, <6,200, <9.0, <13, <8.1, <32, <840, <9.7, <6.8, <67, <150, <MDL, <0.04, <0.046, <0.030, <0.029, <0.045, <0.025, and N/C.
## ACTIONS TAKEN:
## For 'ND' and '<MDL': 'ND' put in ResultQualCode column & made Result blank.
## For numeric values with '<': 'ND' put in ResultQualCode column, numeric value moved to MDL column, & made Result blank.
## For 'E0.02' & 'E0.020': removed 'E' and put 'estimate result' in ResultsComments, & kept numeric value in Result column.
## For 'NA' & 'N/C': made Result blank.
## 'MDL' column is in numeric format
## 'RL' column converted to numeric format
sort(names(AqMaster)); nrow(AqMaster)
##  [1] "Analyte"            "BatchComments"      "BatchVerification"  "CitationCode"      
##  [5] "CollectionComments" "ComplianceCode"     "CoordSystem"        "LabBatch"          
##  [9] "LabSampleID"        "MatrixName"         "MDL"                "MethodName"        
## [13] "Project"            "QACode"             "Result"             "ResultQualCode"    
## [17] "ResultsComments"    "RL"                 "SampleComments"     "SampleDate"        
## [21] "SampleDateTime"     "SampleID"           "SampleTime"         "SampleTypeCode"    
## [25] "SourceID"           "SourceRow"          "StationCode"        "StationName"       
## [29] "TargetLatitude"     "TargetLongitude"    "Unit"               "WBT"
## [1] 45844
sort(names(USGS_new)); nrow(USGS_new)
##  [1] "Analyte"            "BatchComments"      "BatchVerification"  "CitationCode"      
##  [5] "CollectionComments" "ComplianceCode"     "CoordSystem"        "LabBatch"          
##  [9] "LabSampleID"        "MatrixName"         "MDL"                "MethodName"        
## [13] "Project"            "QACode"             "Result"             "ResultQualCode"    
## [17] "ResultsComments"    "RL"                 "SampleComments"     "SampleDate"        
## [21] "SampleDateTime"     "SampleID"           "SampleTime"         "SampleTypeCode"    
## [25] "SourceID"           "SourceRow"          "StationCode"        "StationName"       
## [29] "TargetLatitude"     "TargetLongitude"    "Unit"               "WBT"
## [1] 1554
AqMaster <- rbind(AqMaster, USGS_new)
rm(list=setdiff(ls(), 'AqMaster')) #removes all objects except 'AqMaster'


 ## RUN 14th SCRIPT TO LOAD & MERGE CEDEN FORMATTED DATA ##
source('Reeval_Impl_Goals_Linkage_Analysis/Data/Aqueous/WQP_aq_sed_format-to-ceden.R')
## 'Result' column should be numeric but some cells contain ND.
## For these cases, ND was recorded in the 'ResultQualCode' column and NA recorded in 'Result' column.
## 'MDL' column converted to numeric format
sort(names(AqMaster)); nrow(AqMaster)
##  [1] "Analyte"            "BatchComments"      "BatchVerification"  "CitationCode"      
##  [5] "CollectionComments" "ComplianceCode"     "CoordSystem"        "LabBatch"          
##  [9] "LabSampleID"        "MatrixName"         "MDL"                "MethodName"        
## [13] "Project"            "QACode"             "Result"             "ResultQualCode"    
## [17] "ResultsComments"    "RL"                 "SampleComments"     "SampleDate"        
## [21] "SampleDateTime"     "SampleID"           "SampleTime"         "SampleTypeCode"    
## [25] "SourceID"           "SourceRow"          "StationCode"        "StationName"       
## [29] "TargetLatitude"     "TargetLongitude"    "Unit"               "WBT"
## [1] 47398
sort(names(WQP_new)); nrow(WQP_new)
##  [1] "Analyte"            "BatchComments"      "BatchVerification"  "CitationCode"      
##  [5] "CollectionComments" "ComplianceCode"     "CoordSystem"        "LabBatch"          
##  [9] "LabSampleID"        "MatrixName"         "MDL"                "MethodName"        
## [13] "Project"            "QACode"             "Result"             "ResultQualCode"    
## [17] "ResultsComments"    "RL"                 "SampleComments"     "SampleDate"        
## [21] "SampleDateTime"     "SampleID"           "SampleTime"         "SampleTypeCode"    
## [25] "SourceID"           "SourceRow"          "StationCode"        "StationName"       
## [29] "TargetLatitude"     "TargetLongitude"    "Unit"               "WBT"
## [1] 27098
AqMaster <- rbind(AqMaster, WQP_new)
rm(list=setdiff(ls(), 'AqMaster')) #removes all objects except 'AqMaster'

nrow(AqMaster)
## [1] 74496
# Order columns
AqMaster_final <- AqMaster %>%
  #reorder columns
  select(SourceID, SourceRow, StationName, SampleDateTime, Analyte, Result, MDL, RL, Unit, ResultQualCode, WBT, MatrixName, TargetLatitude, TargetLongitude, CoordSystem,
         StationCode, QACode, CollectionComments, SampleID, SampleComments, SampleTypeCode, ResultsComments, BatchComments, BatchVerification, LabSampleID, LabBatch,
         MethodName, ComplianceCode, Project, CitationCode, SampleDate, SampleTime) %>%
  arrange(SourceID, as.numeric(map_chr(.x=SourceRow, ~gsub('[A-Z]', '', .x)))) #remove letters from SourceRow and sort as if numeric



## SAVE MERGED CEDEN FORMATTED DATA - STILL NEEDS QA/QC FOR GIS SCOPING##
writexl::write_xlsx(AqMaster_final, path='Reeval_Impl_Goals_Linkage_Analysis/Data/Aqueous/1a_AqMaster_merged.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 11:11:35 PST"