Validates specific station IDs against the SNIRH database and returns their current status. This is useful for checking stations before running the full conversion process.
Value
A data.table with the following columns:
- station_id
The station ID that was checked
- found
Logical indicating if station exists in SNIRH
- status
Station status if found, NA if not found
- active
Logical indicating if station is active (status = "ATIVA")
Details
This function is particularly useful for:
Pre-validating station IDs before data conversion
Checking why certain stations fail validation
Getting an overview of station status for reporting
See also
get_snirh_stations for getting all station information
convert_to_snirh for the main conversion function
Examples
# \donttest{
# Check status of specific stations
my_stations <- c("07G/50", "25G/07", "INVALID_ID")
status_check <- check_station_status(my_stations)
#> ! Missing from SNIRH: "INVALID_ID"
print(status_check)
#> Index: <found>
#> station_id found status active
#> <char> <lgcl> <char> <lgcl>
#> 1: 07G/50 TRUE ATIVA TRUE
#> 2: 25G/07 TRUE ATIVA TRUE
#> 3: INVALID_ID FALSE <NA> NA
# Check which stations are not active
inactive <- status_check[active == FALSE | is.na(active)]
if (nrow(inactive) > 0) {
print("Stations requiring attention:")
print(inactive)
}
#> [1] "Stations requiring attention:"
#> station_id found status active
#> <char> <lgcl> <char> <lgcl>
#> 1: INVALID_ID FALSE <NA> NA
# Check only active stations
active_stations <- status_check[active == TRUE]
# }
