bcgov / tidyhydat.ws

An R package that imports Canadian hydrometric data from the ECCC webservice
Apache License 2.0
0 stars 1 forks source link

param_id likely not specified correctly #12

Open boshek opened 3 years ago

boshek commented 3 years ago

See:

library(tidyhydat.ws)       

The following   object is masked _by_ ‘.GlobalEnv’:             param_id
gdelaplante commented 2 years ago

The problem is evident when calling tidyhydat.ws::realtime_ws. If the package isn't loaded via a library() call the package data is not available (or has to be loaded to the global environment via a call to the data) and the following message occurs:

Error in parameters %in% param_id$Parameter : object 'param_id' not found

I am using this tidyhydat.ws function in a package and am having to use some less than ideal work-arounds. Data that is necessary for functions or that doesn't need to be easily accessible should instead live in R/sysdata.rda, from which any function can access it without having the whole package loaded in library.

For a fix, see section 14.2 here: [https://r-pkgs.org/data.html]. I don't think you'd need to change much... the data call in realtime_ws is already written to work with data stored in that manner. There is no need to document internal data so R/data.R would no longer be necessary. Note: this package only has one data object, but multiple data objects would have to get stored in a list and that list passed to usethis::use_data(internal=TRUE) to create a single sysdata.rda file.