Closed KateMMiller closed 4 years ago
When JP and I finished our call in May, I remember needing to make a minor tweak left in nonParTrends, and then everything was running smoothly. I'm not sure if it's because I upgraded to R 4.0 or what, but I'm now having some MAJOR issues with NCRNWater's NETN_Nov2019_Updates branch. Functions that worked before we added type to getSites aren't working. Functions work when site isn't specified (as shown below), but fail when site is specified. I tried debugging but failed to come up with a fix. Example code that works and doesn't is below.
library(NCRNWater) #NETN_Nov2019_Updates branch
library(tidyverse)
library(lubridate)
netnwd<-importNCRNWater(Dir = "D:/NETN/R_Dev/Water/NCRNWaterViz/Data/NETN",
Data = "Water Data.csv",
MetaData = "VizMetaData.csv")
acad <- getParks(netnwd, parkcode = 'ACAD') # Large list (6 MB)
acad2 <- getParkInfo(netnwd, parkcode = 'ACAD') # returns character "Acadia"
acad_info <- getCharInfo(netnwd, parkcode = 'ACAD', info = 'CharName') # character list 1:622 of param names
acad_info_ph <- getCharInfo(netnwd, parkcode = 'ACAD', charname = 'pH', info = "Units")
# character list of 1:41 pH units (assume it's 1/site)
acad_abin_info <- getCharInfo(netnwd, parkcode = "ACAD", sitecode = 'NETN_ACAD_ABIN', info = "type") # fails
Error in (function (classes, fdef, mtable) : unable to find an inherited method for function ‘getSiteInfo’ for signature ‘"character"’ In addition: There were 40 warnings (use warnings() to see them)
warnings()
40 warnings: In .local(object, sitecode, type) : object=Site:No sites match these criteria.
acad_abin_info2 <- getCharInfo(netnwd, parkcode = "ACAD", sitecode = 'NETN_ACAD_ABIN', info = "Details") # fails
Error in (function (classes, fdef, mtable) : unable to find an inherited method for function ‘getChars’ for signature ‘"character"’ In addition: There were 40 warnings (use warnings() to see them)
warnings()
40 warnings: In .local(object, sitecode, type) : object=Site:No sites match these criteria.
acad_abin_site <- getSites(netnwd, parkcode = "ACAD", sitecode = "NETN_ACAD_ABIN") # List of 49
There are 48 warnings (use warnings() to see them)
warnings()
First 40 warnings: In .local(object, sitecode, type) : Object:Site No sites match these criteria. Last 8 warnings: In FUN(X[[i]], ...) : object=Park1:No sites match these criteria.
siteinfo <- getSiteInfo(netnwd, info = "SiteName") # character list 1:67 with netn site names
siteinfo_acad <- getSiteInfo(netnwd, parkcode = "ACAD", info = "SiteName") # fails
Error in (function (classes, fdef, mtable) : unable to find an inherited method for function ‘getSiteInfo’ for signature ‘"character"’ In addition: Warning message: In getSites(object = object, parkcode = parkcode, sitecode = sitecode) :
acad_abin_pH_info <- getCharInfo(netnwd, parkcode = "ACAD", sitecode = 'NETN_ACAD_ABIN', charname = "pH", info = "Details") # fails
Error in (function (classes, fdeg, mtable) : unable to find an inherited method for function 'getChars' for signature '"character"') In addition: There were 40 warnings (use warnings() to see them)
warnings()
40 warnings: In .local(object, sitecode, type) : object=Site:No sites match these criteria.
test <- nonparTrends(netnwd, parkcode = "ACAD", sitecode = "NETN_ACAD_ANTB", charname = 'pH')
Error in (function (classes, fdef, mtable) :
unable to find an inherited method for function ‘getWData’ for signature ‘"character"’
In addition: There were 40 warnings (use warnings() to see them)
warnings()
40 warnings: In .local(object, sitecode, type) : object=Site:No sites match these criteria.
I fixed the problems that were happening in getSites and causing other functions to fail. The PR is ready for review.
I reprogrammed nonparTrends() to be an S4 function, added more error handling and features in waterseries and nonparTrends, and fixed documentation errors and typos.