导入多个年度天气数据,并通过循环将其组合成数据框(Import multiple yearly weather data , and combine it into a dataframe by lo

编程入门 行业动态 更新时间:2024-10-18 18:23:34
导入多个年度天气数据,并通过循环将其组合成数据框(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) ) )

更多推荐

本文发布于:2023-08-07 06:32:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1463082.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:成数   组合   多个   将其   天气

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!