2

I am trying to convert/parse a JSON string in R, but am having trouble.

I have installed both rjson and RJSONIO packages.

library(rjson)
install.packages("rjson")
require(rjson)

Example row of a dataset:

dataset <- data.frame(id = c(1), signup_get = {\\1358183137\\:{\\self\\:\\/index.php\\,\\pv\\:\\2\\},\\1358183315\\:{\\self\\:\\/sail-inventory-tracking.php\\},\\1358183434\\:{\\self\\:\\/pricing.php\\},\\1358183473\\:{\\self\\:\\/tour-keep-track.php\\},\\1358183486\\:{\\self\\:\\/tour-save-time.php\\},\\1358183503\\:{\\self\\:\\/tour-sell-more.php\\},\\1358183600\\:{\\self\\:\\/tour-integrations.php\\},\\1358183631\\:{\\self\\:\\/pricing.php\\},\\1358184267\\:{\\self\\:\\/signup.php\\,\\get\\:{\\p\\:\\1\\}},\\1358184409\\:{\\self\\:\\/pricing.php\\},\\1358184436\\:{\\self\\:\\/pricing.php\\},\\1358184485\\:{\\self\\:\\/about.php\\},\\1358184497\\:{\\self\\:\\/pricing.php\\},\\1358184574\\:{\\self\\:\\/pricing.php\\},\\1358184595\\:{\\self\\:\\/about.php\\},\\1358184606\\:{\\self\\:\\/tour-keep-track.php\\},\\1358184612\\:{\\self\\:\\/tour-sell-more.php\\}}
dataset$signup_get <- toString(dataset$signup_get)

I have tried to call fromJSON(data$signup_get, method = "C", unexpected.escape = "error") but get the error "Error in function (classes, fdef, mtable): unable to find an inherited method for function "fromJSON", for

Some of my primary goals are to answer questions such as:

  • What was the last entry (most recent) in the JSON string?
  • How much time passed between first time period and last in JSON string? (Time is listed as epoch time)
  • How many pages were visited

I think my error might be in how I am importing the data. Any suggestions would be great.

user1489719
  • 119
  • 1
  • 6
  • 12
  • 1
    Your example does not work. It requires quotes around the JSON part and you did not close the parentheses for data.frame(). And when these errors are corrected, I cannot replicate your fromJSON() error. – neilfws Mar 26 '13 at 21:18

0 Answers0