Search code examples
rtwittererror-handlingrep

Error in rep(space, max_width) : invalid 'times' argument; in one column


I'm working on two data frames which contain tweet data from two different accounts. The first data frame is working on this twitter account and returns a data frame in my R console.

baudet_tweets <- userTimeline("thierrybaudet", n = 3200, includeRts = TRUE)
baudet_tweets_df <- tbl_df(map_df(baudet_tweets, as.data.frame))

However, the same code for a different twitter account gives me the error:

klaver_tweets <- userTimeline("jesseklaver", n = 3200, includeRts = TRUE)
klaver_tweets_df <- tbl_df(map_df(klaver_tweets, as.data.frame))

Error in rep(space, max_width) : invalid 'times' argument

I think it's the text column because when I filter outselect(klaver_tweets_df, text) the text column the code works. But I need the text column for textanalysis... I find it strange that the text column of baudet_tweets_df just works. My code is not really reproducible but here is an image of the df because I CAN View(klaver_tweets_df). Maybe onlyklaver_tweets_df` contains emoticons? If so how can I remove them?

df$text klaver


Solution

  • Removing the emoji's did the trick!

    klaver_tweets_df$text <- gsub("[^\x01-\x7F]", "", klaver_tweets_df$text)