One-hot vector for fixed vocabulary
library(quanteda)

mytext &lt;- c(oldtext = &quot;I want this cat&quot;)
dtm_old &lt;- dfm(mytext)
dtm_old

newtext &lt;- c(newtext = &quot;You are the dog here&quot;)
dtm_new &lt;- dfm(newtext)
dtm_new

dtm_matched &lt;- dfm_match(dtm_new, featnames(dtm_old))
dtm_matched

$V_1$
Document-feature matrix of: 1 document, 4 features (100.0% sparse).
         features
docs      i want this cat
  newtext 0    0    0   0

$V_2$
Document-feature matrix of: 1 document, 4 features (75.0% sparse).
         features
docs      i want this cat
  newtext 1    0    0   0

$V_3$
Document-feature matrix of: 1 document, 4 features (75.0% sparse).
         features
docs      i want this cat
  newtext 0    0    0   3

Of course when using a &quot;one hot&quot; vectorizer, &quot;cat&quot; in $V_3$ would be 1 (instead of the count).