如何在fromJSON命令中的url中传递变量 [英] How to pass a variable in url in fromJSON command

查看:138
本文介绍了如何在fromJSON命令中的url中传递变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在url中传递变量并使用jsonlite进行展平,但是我无法使用循环传递变量页面.如何使用FromJSON循环播放?

I am trying to pass a variable in the url and flatten using jsonlite, but i am not able to pass variable pages using the loop. How do i loop using FromJSON?

pages<- list()
for(i in 1:20) {
mydata <- fromJSON("https:www.example.com/page="+i+"&access_token=xyz", flatten = TRUE) 
}
filings <-rbind.pages(pages)

推荐答案

这怎么办?

pages<- list()
for(i in 1:20) {
  mydata <- fromJSON(paste("https:www.example.com/page=", i, "&access_token=xyz", sep = "+"), flatten = TRUE)
}
filings <-rbind.pages(pages)

这篇关于如何在fromJSON命令中的url中传递变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆