0

I am trying to plot a timeline with the tweets from the User ID followed by "Spotify", my code is as below, but I've got an error message:

## get user IDs of accounts followed by Spotify

tmls <- get_timelines(c("Spotify","Pandora", n = 3200))

## plot the frequency of tweets for each user over time
tmls %>%    
  dplyr::filter(created_at > "2018-8-3") %>%    
  dplyr::group_by(screen_name) %>%    
  ts_plot("days", trim = 1L) +    
  ggplot2::geom_point() +    
  ggplot2::theme_minimal() +    
  ggplot2::theme(
    legend.title = ggplot2::element_blank(),    
    legend.position = "bottom",    
    plot.title = ggplot2::element_text(face = "bold")) +    
  ggplot2::labs(    
    x = NULL, y = NULL,    
    title = "Frequency of Twitter statuses posted by streaming music companies",    
    subtitle = "Twitter status (tweet) counts aggregated by day from July/August 2018",    
    caption = "\nSource: Data collected from Twitter's REST API via rtweet"
  )

The error message is as below:

Error in .subset2(x, i) :     
  attempt to select less than one element in get1index

I really do not know what to try to troubleshoot this anymore. Any help is highly appreciated!!

divibisan
  • 11,659
  • 11
  • 40
  • 58
Chen
  • 383
  • 2
  • 12
  • 1
    I'm pretty sure that your problem is with your `filter` statement where you try to use a mathematical operator `>` with a string `'2018-8-3'`. You need to convert your `created_at` variable and the target date to `Date` objects to do the kind of filtering you want. Once you fix that, the graphing should work fine. – divibisan Aug 03 '18 at 20:47
  • Got you!!! Thanks~~^~^ – Chen Aug 04 '18 at 01:01
  • Have you solved your problem? If not, you should edit your question and add a representative example of your `tmls` dataset. Please read [Ask] and [How to make a great R reproducible example?](https://stackoverflow.com/q/5963269/8366499) for examples. – divibisan Aug 06 '18 at 16:21

0 Answers0