一個非常簡單的問題。 我試圖創建for循環在這個不同的數據幀:R編程:如何在for循環中創建幾個數據框架
for (i in seq_along(country_code)) { UrlRoot<-"http://climatedataapi.worldbank.org/climateweb/rest/v1/country/cru/tas/month/" fileUrl <- paste(UrlRoot,country_code[i],sep = "") get_tas <- fromJSON(fileUrl) climate_data <- rbind(climate_data,get_tas)
我的目標是創建每包含氣候數據,我可以從API獲得國家的數據幀。像:
AWA
month data
0 21
1 21.3
... ....
AFG
0 19.5
1 22.4
... ....
但我不能將其他數據存儲在不同的數據框中的國家的數據。這是我得到:
month data
1 0 26.49174100
2 1 26.67431300
3 2 27.21926500
4 3 27.64128500
5 4 28.24770500
6 5 28.43945000
7 6 28.56605500
8 7 28.79541400
9 8 28.83853100
10 9 28.36330200
11 10 27.78715500
12 11 27.09082600
13 0 0.09617378
14 1 2.24567600
15 2 7.38042300
16 3 13.16199500
17 4 18.25324400
18 5 23.07769600
19 6 25.17552200
20 7 23.81981300
任何提示?非常感謝!!