0

I am trying to work with JSON in R Studio and have installed the RJSONIO and Rcurl packages successfully but the getURL function is not working. I keep getting an error saying that the getURL function cannot be found.

  package ‘RCurl’ successfully unpacked and MD5 sums checked
  Warning in install.packages :
  cannot remove prior installation of package ‘RCurl’

 > AccidentURL <- "http://data.maryland.gov/api/views/pdvh-tf2u/rows.json? 
 accessType=DOWNLOAD"
 > apiResult <- getURL(AccidentURL)
 Error in getURL(AccidentURL) : could not find function "getURL"

Any suggestions on how to get this function to work or how to build the function myself would be appreciated.

SLG333
  • 79
  • 2
  • 11

1 Answers1

1
library(httr)
AccidentURL <- "http://data.maryland.gov/api/views/pdvh-tf2u/rows.json?accessType=DOWNLOAD"
apiResult <- GET(AccidentURL)

output

apiResult
    Response [http://data.maryland.gov/api/views/pdvh-tf2u/rows.json?accessType=DOWNLOAD]
      Date: 2018-11-10 17:33
      Status: 200
      Content-Type: application/json; charset=utf-8
      Size: 6.23 MB
    {
      "meta" : {
        "view" : {
          "id" : "pdvh-tf2u",
          "name" : "2012 Vehicle Collisions Investigated by State Police",
          "attribution" : "Maryland State Police",
          "averageRating" : 0,
          "category" : "Public Safety",
          "createdAt" : 1367604900,
          "description" : "Collisions investigated by the Maryland State Police in 2012 (does not include collisions investigated by local jurisdictions).",
    ...
Aleksandr
  • 1,814
  • 11
  • 19