I am attempting to use the streamR
in R to download and analyze Twitter, under the pretense that this library can overcome the limitations from the twitteR
package.
When downloading data everything seems to work fabulously, using the filterStream
function (just to clarify, the function captures Twitter data, just running it will provide the json file -saved in the working directory- that needs to be used in further steps):
filterStream( file.name="tweets_test.json",
track="NFL", tweets=20, oauth=credential, timeout=10)
Capturing tweets...
Connection to Twitter stream was closed after 10 seconds with up to 21 tweets downloaded.
However, when moving on to parse the json
file, I keep getting all sorts of errors:
readTweets("tweets_test.json", verbose = TRUE)
0 tweets have been parsed.
list()
Warning message:
In readLines(tweets) : incomplete final line found on 'tweets_test.json'
Or with this function from the same package:
tweet_df <- parseTweets(tweets='tweets_test.json')
Error in `$<-.data.frame`(`*tmp*`, "country_code", value = NA) :
replacement has 1 row, data has 0 In addition: Warning message: In stream_in_int(path.expand(path)) : Parsing error on line 0
I have tried reading the json
file with jsonlite
and rjson
with the same results.
Originally, it seemed that the error came from special characters ({, then \)
within the json
file that I tried to clean up following the suggestion from this post, however, not much came out of it.
I found out about the streamR
package from this post, which shows the process as very straight forward and simple (which it is, except for the parsing part!).
If any of you have experience with this library and/or these parsing issues, I'd really appreciate your input. I have been searching non stop but haven't been able to locate a solution.
Thanks!