Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Using the package rtweet, I have streamed some tweets and saved them in a JSON file.

When using the following: tweets_df <- parse_stream('file.json'), I get the following error during the process:

enter image description here

Does anyone have any idea how to fix this so that the JSON file can be read into R as a data frame?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
305 views
Welcome To Ask or Share your Answers For Others

1 Answer

Have you tried it this way? I don't personally use rtweet but work with json files.

#load library to read json
library(jsonlite)
json_data <- fromJSON("db.json")

It reads it as a nested list but then you can simply change it to a dataframe using df<-rlist::list.stack(x, fill=TRUE )'

You might have to adapt it and for example use a loop if your json file contains several users.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...