Error : Not all elements of twList are of the same class, when I convert the tweets with all variables to dataframe

Clash Royale CLAN TAG#URR8PPP
Error : Not all elements of twList are of the same class, when I convert the tweets with all variables to dataframe
I am using rtweet package in R to extract tweets of particular hashtag which basically needs appname,api_key,api_secret,access_token,access_token_secret.
So i have created an app in Twitter to get all the above details. And then I pass the above as follows
twitter_token <- create_token(
app = appname,
consumer_key = api_key,
consumer_secret = api_secret)
tweets <-search_tweets("#iPhone8", n=1000, include_rts = FALSE, type = "recent",lang = "en")
So this will basically extract tweets with 88 variables. Now I want to write these tweets to an excel file for further analysis.
And for that I am using the below code.
tweets.df <-twListToDF(tweets)
When I run this I am getting the following error.
Error in twListToDF(tweets) :
Not all elements of twList are of the same class
Just want to understand what could be the potential issue here.
Problem is I cannot put the exact code here as that needs my api key and all.
Any help would be really appreciated.
Regards,
Akash
tweets
write.csv(tweets, 'file/path/to/write)
twListToDF
rtweet
twitteR
Thanks Ronak for quick reply. I am using twitteR for this function. When I try to write directly to csv, I get this error. Error in write.csv(tweets, file ='c:/Akash/Raw.csv', row.names = F ) unimplemented type 'list' in 'EncodeElement'
– Akash
Aug 13 at 6:14
Can you check if any of the column is a list in
tweets ? You need to unlist it first before writing it to csv I suppose.– Ronak Shah
Aug 13 at 6:20
tweets
unlist
and how do I check that ? There are 88 columns. So is there any way I can check it using commands ?
– Akash
Aug 13 at 6:34
sapply(tweets, class) will give you all classes of all the columns.– Ronak Shah
Aug 13 at 6:44
sapply(tweets, class)
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
tweetsis already a data frame right? So why not dowrite.csv(tweets, 'file/path/to/write)? Moreover, I do not seetwListToDFfunction inrtweetpackage. As far as I can recall it was there in oldtwitteRpackage.– Ronak Shah
Aug 13 at 6:06