Last active
March 17, 2021 12:07
-
-
Save adamhsparks/45efe2589286ed871b0f875a99c756ad to your computer and use it in GitHub Desktop.
Download and calculate country and year mean values for weather variables using GSODR and dplyr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library("GSODR") | |
library("tidyr") | |
library("dplyr") | |
library("countrycode") | |
w <- get_GSOD(years = 1929:1931) | |
w <- | |
w %>% | |
group_by(CTRY, YEAR) %>% | |
summarise( | |
TEMP = mean(TEMP, na.rm = TRUE), | |
MAX = mean(MAX, na.rm = TRUE), | |
MIN = mean(MIN, na.rm = TRUE), | |
PRCP = mean(PRCP, na.rm = TRUE), | |
RH = mean(RH, na.rm = TRUE), | |
WDSP = mean(WDSP, na.rm = TRUE) | |
) %>% | |
left_join(codelist, by = c("CTRY" = "fips")) %>% # add country names and codes | |
select(c( | |
"CTRY", | |
"YEAR", | |
"TEMP", | |
"MIN", | |
"PRCP", | |
"RH", | |
"WDSP", | |
"iso3c", | |
"iso2c", | |
"country.name.en" | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment