title: How to find and plot frequencies of multiple phrases totalled?
body: <p>I have corpus and I am trying to find the frequencies of multiple phrases totalled by year and plot this. For example, if the phrase &quot;American economy&quot; and &quot;Canadian economy&quot; is mentioned 2 times each in 2004, I would want this to give a frequency of 4 in 2004.</p>
  <p>I have managed to do this for single tokens, but am having trouble trying it for phrases.
  This is the code I used to do for single tokens.</p>
  <pre><code>a_corpus &lt;- corpus(df, text = &quot;text&quot;)
  
  my_dict &lt;- dictionary(list(america = c(&quot;America&quot;, &quot;President&quot;)))
                        
  freq_grouped_creators &lt;- textstat_frequency(dfm(tokens(a_corpus)), 
                                 groups = a_corpus$Year)
  
  freq_word_creators &lt;- subset(freq_grouped_creators, freq_grouped_creators$feature %in% my_dict$america)
  
  # collapsing rows by year to total frequencies for tokens
  freq_word_creators_2 &lt;- freq_word_creators %&gt;% 
                             group_by(group) %&gt;%
                             summarize(Sum_frequency = sum(frequency))
  
  # plotting
  ggplot(freq_word_creators_2, aes(x = group, y = 
      Sum_frequency)) +
      geom_point() +
      scale_y_continuous(limits = c(0, 300), breaks = c(seq(0, 300, 30))) +
      xlab(NULL) +
      ylab(&quot;Frequency&quot;) +
      theme(axis.text.x = element_text(angle = 90, hjust = 1))
  </code></pre>