Skip to content

Instantly share code, notes, and snippets.

@multidis
Created May 21, 2014 12:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save multidis/e410db279ae0bb240c43 to your computer and use it in GitHub Desktop.
Save multidis/e410db279ae0bb240c43 to your computer and use it in GitHub Desktop.
Query web address and get json or csv data in R.
library(RJSONIO)
## url <- "http://www....."
dat.ls <- fromJSON(url)[[1]] ## verify list structure - element edit as needed
dat.df <- data.frame(do.call(rbind, dat.ls))
library(RCurl)
## purl <- "http://www....."
page.txt <- getURL(purl)
page.dat <- read.csv(text=txt, header=TRUE, stringsAsFactors=FALSE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment