Closed hansthompson closed 9 years ago
library(dplyr) library(stationaRy) #get Alaska stations stations <- get_isd_stations(lower_lat = 50.943870, upper_lat = 71.545427, lower_lon = -179.652659, upper_lon = -125.405937) %>% filter(country == "US", state == "AK") a_row <- stations[13,] #doesn't work station_data <- a_row %>% select_isd_station(name = a_row$name) %>% get_isd_station_data(startyear = a_row$begin, endyear = a_row$end) #works a_row %>% select_isd_station(name = "WAINWRIGHT \\(DEW\\)") %>% get_isd_station_data(startyear = a_row$begin, endyear = a_row$end) # add a function to handle special characters from http://stackoverflow.com/questions/14836754/is-there-an-r-function-to-escape-a-string-for-regex-characters re.escape <- function(strings){ vals <- c("\\\\", "\\[", "\\]", "\\(", "\\)", "\\{", "\\}", "\\^", "\\$","\\*", "\\+", "\\?", "\\.", "\\|") replace.vals <- paste0("\\\\", vals) for(i in seq_along(vals)){ strings <- gsub(vals[i], replace.vals[i], strings) } strings } #works a_row %>% select_isd_station(name = re.escape(a_row$name)) %>% get_isd_station_data(startyear = a_row$begin, endyear = a_row$end)
This has now been implemented. Thanks very much for the contribution!