0
> orioles.tweets <- searchTwitter('#orioles', n=15, lang="en")
> orioles.text=laply(orioles.tweets,function(t) t$getText())
> class(toJSON(orioles.text))
[1] "character"

Why does this happen?

VBB
  • 15
  • 6
  • 1
    You have not explained what is unexpected in this result. – IRTFM Dec 05 '15 at 17:56
  • toJSON() must convert the tweets to json format. So class(toJSON(orioles.text)) should give me the result "json" – VBB Dec 07 '15 at 13:39

1 Answers1

0

It is unclear why you would think that the class should be "json". Presumably you are using one of the R packages that has a toJSON function. Choosing the rjsom package as a test case, I find that the first example in ?toJSON-help page gives "character" as the class for the retruned object:

> ??toJSON
> library(rjson); x <- list( alpha = 1:5, beta = "Bravo", 
+            gamma = list(a=1:3, b=NULL), 
+            delta = c(TRUE, FALSE) )
> json.vec <- toJSON( x )
> class(json.vec)
[1] "character"

If you are getting errors from subsequent proccessing because the class is not correctly set, you can assign a class:

class(json.vec) <- "json"

This is generally not advised, but it might be needed in situations where the choice of the json-wrangling library was not the same one as was chosen by another package author.

IRTFM
  • 258,963
  • 21
  • 364
  • 487