title: How to search for specific terms in a DTM
body: <p>I have a dataset of 200+ pdf's that I converted into a corpus. I'm using the TM package for R for text pre-processing and mining. 
  So far, I've successfully created the DTM (document term matrix) and can find the x most frequently occuring terms.
  The goal of my research however, is to check if certain terms are used in the corpus. I'm not so much looking for the most frequent terms, but have my own list of terms that I want to check if they occur, and if so, how many times.</p>
  
  <p>So far, I've tried this:</p>
  
  <pre><code>function &lt;- content_transformer(function(x, pattern)regmatches(x,gregexpr(pattern, x, perl=TRUE, ignore.case = TRUE)))
  keep = "word_1|word_2"
  tm_map(my_corpus, function, keep)[[1]]
  </code></pre>
  
  <p>and these:</p>
  
  <pre><code>str_detect(my_corpus, "word_1", "word_2" )
  str_locate_all(my_corpus, "word_1", "word_2")
  str_extract(my_corpus, "funds")
  </code></pre>
  
  <p>This last one seems to come closest giving the output:
      [1] "funds" NA      NA </p>
  
  <p>Neither seems to be giving me what I need.</p>