我正在使用Bomrang软件包中的get_historical_weather函数。 而不是手动指定纬度和经度详细信息(例如get_historical(latlon = c(-28.016666,153.399994),type =“ rain”)),我需要使用现有列表中的纬度和经度详细信息。 我尝试过使用for循环,但没有成功。任何帮助将不胜感激!
谢谢
答案 0 :(得分:0)
另一种实现方法是使用purrr
包
library(bomrang)
library(purrr)
coords <- structure(list(lat = c(-28.01666, -33.8688),
lon = c(153.399994, 151.2093)),
row.names = c(NA, -2L),
class = c("tbl_df", "tbl", "data.frame"))
x <- purrr::map2(.x = coords$lat, .y = coords$lon, .f = ~get_historical(latlon = c(.x, .y), type = "rain"))
#> Closest station: 040764 (GOLD COAST SEAWAY)
#> Data saved as /tmp/RtmpJkn04r/IDCJAC0009_040764_1800_Data.csv
#> Closest station: 066062 (SYDNEY (OBSERVATORY HILL))
#> Data saved as /tmp/RtmpJkn04r/IDCJAC0009_066062_1800_Data.csv
由reprex package(v0.2.1)于2019-05-28创建