ent">## nouns</span>
x$term_noun &lt;- ifelse(x$upos %<span class="hljs-keyword">in</span>% <span class="hljs-string">"NOUN"</span>, x$token, <span class="hljs-literal">NA</span>)

<span class="hljs-comment">## Build document/term/matrix </span>
dtm &lt;- document_term_frequencies(x, document = <span class="hljs-string">"topic_level_id"</span>, term = c(<span class="hljs-string">"term_noun"</span>, <span class="hljs-string">"mwe"</span>))
dtm &lt;- document_term_matrix(x = dtm)
dtm &lt;- dtm_remove_lowfreq(