-
This may be a naive question, but is there a way to check whether a given station has flow data or level data prior to calling Thanks! Appreciate any insight on this. Rob |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Definitely deleted the wrong one. Not a naive question at all. Great idea. I think the best approach would be to query the data a la: library(tidyhydat)
library(dbplyr)
library(dplyr)
hy_check_for_data <- function(station_number, hydat_table) {
hydat_con <- hy_src()
tbl(hydat_con, hydat_table) %>%
filter(STATION_NUMBER %in% station_number) %>%
group_by(STATION_NUMBER) %>%
summarise(
nrows = n(),
min_year = min(YEAR, na.rm = FALSE),
max_year = max(YEAR, na.rm = FALSE)
)
}
hy_check_for_data(c("08MF005", "fffff"), "DLY_FLOWS")
#> # Source: lazy query [?? x 4]
#> # Database: sqlite 3.36.0
#> # [C:\Users\salbers\AppData\Local\tidyhydat\tidyhydat\Hydat.sqlite3]
#> STATION_NUMBER nrows min_year max_year
#> <chr> <int> <int> <int>
#> 1 08MF005 1294 1912 2019 Then inside the function once you have it in R do a |
Beta Was this translation helpful? Give feedback.
Definitely deleted the wrong one. Not a naive question at all. Great idea. I think the best approach would be to query the data a la: