Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates to weather to remove missing values / adjust tz #25

Merged
merged 7 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ Imports:
curl,
usethis,
roxygen2,
progress
progress,
tidyr
URL: https://github.com/simonpcouch/anyflights, https://simonpcouch.github.io/anyflights/
BugReports: https://github.com/simonpcouch/anyflights/issues
RoxygenNote: 7.2.3
Expand Down
9 changes: 8 additions & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -438,9 +438,16 @@ get_weather_for_station <- function(station, year, dir,
month = as.integer(lubridate::month(time)),
day = lubridate::mday(time),
hour = lubridate::hour(time),
time_hour = ISOdatetime(year, month, day, hour, 0, 0)) %>%
# ensure output isn't shifted for current timezone of user
time_hour = ISOdatetime(year, month, day, hour, 0, 0,
tz = "GMT")) %>%
# filter to only relevant rows - necessary for discontinuous month ranges
dplyr::filter(month %in% !!month) %>%
# fill in missing values with the only value given in a particular hour
dplyr::group_by(time_hour) %>%
tidyr::fill(temp, dewp, humid, precip, pressure, # Fill NAs
.direction = "downup") %>%
dplyr::ungroup() %>% # Ungroup to return to original data structure
ismayc marked this conversation as resolved.
Show resolved Hide resolved
# remove duplicates / incompletes
dplyr::group_by(origin, month, day, hour) %>%
dplyr::filter(dplyr::row_number() == 1) %>%
Expand Down