我希望从R中的多个JSON API调用中创建一个大型数据集。当我运行我的代码时,它返回零错误,但是它产生一个空的数据框(称为all_prices)。这是我使用的代码:
library(jsonlite)
library(data.table)
library(anytime)
library(xts)
library(quantmod)
response <- fromJSON('https://www.cryptocompare.com/api/data/coinlist')
cryptocurrencies <- data.table::rbindlist(response$Data, fill=TRUE)
for (i in 1:10) {
prices <- fromJSON(paste0("https://min-api.cryptocompare.com/data/histoday?
fsym=",as.character(cryptocurrencies[1,5]),
"&tsym=USD&allData=true&e=CCCAGG"))
prices <- data.frame(prices$Data)
prices$Symbol <- rep(cryptocurrencies[1,5],nrow(prices))
all_prices = do.call(rbind, prices)
}
我希望每个交互都通过rbind附加到数据帧上,以创建一个融化的数据集。
我认为问题出在"do.call“函数中,不过我猜是这样的。谢谢
转载请注明出处:http://www.xiangbinbaiyi.com/article/20230526/2189120.html