title: Plot Count/frequency of tweets for word by month
body: <p>I have connected R to Twitter and am scraping using the <code>searchTwitter</code> function in R, and cleaning the resultant data for punctuation, lowercase, etc. Now I'm trying to do the following:</p>
  
  <ul>
  <li><em>count</em> the number of tweets with the word "<em>auction</em>" that have been tweeted per month since <em>Jan 2015</em> until the end of July 2015.</li>
  <li>Plot the count in a simple bar chart (<code>x-axis - month</code>; <code>y-axis - number of tweets</code>).</li>
  </ul>
  
  <p>I'd like to reuse this for <em>retweets</em>, <em>mentions</em>, <em>replies</em> and <em>favorites</em>.</p>
  
  <p>This is what I've tried so far:</p>
  
  <pre><code>#load the packages into R
  &gt;library(twitteR)
  &gt;library(plyr)
  &gt;library(ggplot2)    
  
  # Register an application (API) at https://apps.twitter.com/
  # Look up the API key and create a token – you need for both the key and the secret
  # Assign the keys to variables and use the authorization
  api_key &lt;- “your API key from twitter”
  api_secret &lt;- “your Secret key from twitter”
  access_token &lt;- “you Access Token from twitter”
  access_token_secret &lt;- “you Access Token Secret key from twitter”
  setup_twitter_oauth(api_key,api_secret,access_token,access_token_secret)
  </code></pre>
  
  <blockquote>
    <p><a href="https://www.miskatonic.org/2012/10/21/accessyul-tweets-chart/" rel="nofollow">1</a> "Using direct authentication"
      Use a local file to cache OAuth access credentials between R sessions?<br>
        1: Yes<br>
        2: No<br>
        # Type 1 and press Enter<br>
        Selection: 1  </p>
  </blockquote>
  
  <pre><code>auctiontweets &lt;- searchTwitter("auction", since = "2015-01-01", until = "2015-08-03", n=1000)
  </code></pre>
  
  <p>However, I'm having trouble creating a data frame, getting the following error:</p>
  
  <pre><code>tweet.dataframe &lt;- data.frame(searchTwitter("action", since = "2015-01-01", until = "2015-08-03", n=3000))
  </code></pre>
  
  <blockquote>
    <p>Error in as.data.frame.default(x[[i]], optional = TRUE) :<br>
        cannot coerce class "structure("status", package = "twitteR")" to a data.frame</p>
  </blockquote>
  
  <p>I found code on how to plot users by hour; but wasn't able to modify it so that it works for tweets with a specific word (i.e. 'auction') per month:</p>
  
  <pre><code>yultweets &lt;- searchTwitter("#accessyul", n=1500)
  y &lt;- twListToDF(yultweets)
  y$created &lt;- as.POSIXct(format(y$created, tz="America/Montreal"))
  yply &lt;- ddply(y, .var = "screenName", .fun = function(x) {return(subset(x,     
  created %in% min(created), select = c(screenName,created)))})
  yplytime &lt;- arrange(yply,-desc(created))
  y$screenName=factor(y$screenName, levels = yplytime$screenName)
  ggplot(y) + geom_point(aes(x=created,y=screenName)) + ylab("Twitter username") + xlab("Time")
  </code></pre>
  
  <p>The source can be found <a href="https://www.miskatonic.org/2012/10/21/accessyul-tweets-chart/" rel="nofollow">here</a>.</p>