导入多个年度天气数据,并通过循环将其组合成数据框(Import multiple yearly weather data , and combine it into a dataframe by loop)
library(weatherData)
for(i in 2003:2016) {
c <- (getWeatherForYear(station_id = "BOS", year = i))
}
我正在编写一个循环来获取从2003年到2016年的天气数据:getWeatherForYear并将其合并到数据框中
但循环后,数据框仅显示2016年的天气数据“不是从2003年到2016年”
有人可以帮我修复产生数据帧的循环,包括从2003年到2016年的年度天气数据吗?
非常感谢
library(weatherData) for(i in 2003:2016) { c <- (getWeatherForYear(station_id = "BOS", year = i)) }I am writing a loop to get the weather data from year 2003 to year 2016 from the function: getWeatherForYear and combine it into a dataframe
But after looping, dataframe only shows the weather data in year 2016 "not from year 2003 to 2016"
Could someone help me for fixing the loop that will produce a dataframe include the yearly weather data from year 2003 to 2016?
Thanks a lot
最满意答案
df <- do.call( rbind, lapply( 2003:2016, function(i) getWeatherForYear(station_id = "BOS", year = i) ) ) df <- do.call( rbind, lapply( 2003:2016, function(i) getWeatherForYear(station_id = "BOS", year = i) ) )更多推荐
发布评论