ropensci / tidyhydat

An R package to import Water Survey of Canada hydrometric data and make it tidy
https://docs.ropensci.org/tidyhydat
Apache License 2.0
70 stars 19 forks source link

Expose attributes on realtime data #160

Closed DaveHutch closed 2 years ago

DaveHutch commented 3 years ago

Describe the bug The returned tibble from tidyhydat::realtime_dd() contains attributes: 'Queried on:' and 'Date range:' but are not accessible through attr() command.

To Reproduce rt_data <- tidyhydat::realtime_dd(station_number = "07EA004")

head(rt_data)

Expected behavior

head(rt_data) Queried on: 2021-09-02 23:27:35 (UTC) Date range: 2021-08-03 to 2021-08-03

A tibble: 6 x 8

STATION_NUMBER PROV_TERR_STATE_LOC Date Parameter Value Grade Symbol Code

1 07EA004 BC 2021-08-03 08:00:00 Flow 47.5 NA NA 1 2 07EA004 BC 2021-08-03 08:05:00 Flow 47.4 NA NA 1 3 07EA004 BC 2021-08-03 08:10:00 Flow 47.5 NA NA 1
boshek commented 2 years ago

Thanks for this. I think with the range data it is probably best accessed through normal R tools like:

R> rt_data <- tidyhydat::realtime_dd(station_number = "07EA004")

R> range(rt_data$Date)
[1] "2021-08-08 08:00:00 UTC" "2021-09-07 19:30:00 UTC"

I will however add the query time as an attributes to be accessed like:

attributes(rt_data)$query_time