diff --git a/NEWS.md b/NEWS.md index 236603d..e3d58dc 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,6 +2,8 @@ - Transfered maintainance of package to Jeremy Weiss - Timestamp for hourly and daily maximum two-minute sustained wind speeds, `wind_2min_timestamp` now appears in downloaded data +- Variable type for hourly and daily `wind_2min_timestamp` now is date-time instead of character with correct time zone, `tzone = "America/Phoenix"` +- Values for hourly `date_datetime` variable now have `tzone = "America/Phoenix"` assigned # azmetr 0.2.0 diff --git a/R/az_daily.R b/R/az_daily.R index e9ebcc3..b4b49b1 100644 --- a/R/az_daily.R +++ b/R/az_daily.R @@ -89,9 +89,23 @@ az_daily <- function(station_id = NULL, start_date = NULL, end_date = NULL) { #convert NAs dplyr::mutate( dplyr::across( - tidyselect::where(is.numeric), + tidyselect::where(is.numeric), function(x) - dplyr::if_else(x %in% c(-999, -9999, -99999, -7999, 999, 999.9, 9999), NA_real_, x)) + dplyr::if_else(x %in% c(-999, -9999, -99999, -7999, 999, 999.9, 9999), NA_real_, x) + ) + ) %>% + dplyr::mutate( + wind_2min_timestamp = dplyr::if_else( + wind_2min_timestamp == as.character(-99999), + NA_character_, + wind_2min_timestamp + ) + ) %>% + dplyr::mutate( + wind_2min_timestamp = lubridate::with_tz( + lubridate::parse_date_time(.data$wind_2min_timestamp, orders = "ymdHMSz"), + tzone = "America/Phoenix" + ) ) return(out) } diff --git a/R/az_hourly.R b/R/az_hourly.R index 18ec1b2..f4e3ac1 100644 --- a/R/az_hourly.R +++ b/R/az_hourly.R @@ -91,13 +91,33 @@ az_hourly <- function(station_id = NULL, start_date_time = NULL, end_date_time = as.numeric )) %>% dplyr::filter(.data$meta_station_id != "az99") %>% - dplyr::mutate(date_datetime = lubridate::ymd_hms(.data$date_datetime)) %>% + dplyr::mutate( + date_datetime = + lubridate::force_tz( + lubridate::ymd_hms(.data$date_datetime), + tzone = "America/Phoenix" + ) + ) %>% #convert NAs dplyr::mutate( dplyr::across( tidyselect::where(is.numeric), function(x) dplyr::if_else(x %in% c(-999, -9999, -99999, -7999, 999, 999.9, 9999), NA_real_, x)) + ) %>% + dplyr::mutate( + wind_2min_timestamp = dplyr::if_else( + wind_2min_timestamp == as.character(-99999), + NA_character_, + wind_2min_timestamp + ) + ) %>% + dplyr::mutate( + wind_2min_timestamp = + lubridate::with_tz( + lubridate::parse_date_time(.data$wind_2min_timestamp, orders = "ymdHMSz"), + tzone = "America/Phoenix" + ) ) return(out) }