How to pass a variable in url in fromJSON command

爷,独闯天下 提交于 2019-12-11 08:53:30

问题


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)

回答1:


What about this?

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)


来源:https://stackoverflow.com/questions/26941044/how-to-pass-a-variable-in-url-in-fromjson-command

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!