title: tidytext, quanteda, and tm returning different tf-idf scores
body: <p>I am trying to work on tf-idf weighted corpus (where I expect tf to be a proportion by document rather than simple count). I would expect the same values to be returned by all the classic text mining libraries, but I am getting different values. Is there an error in my code (e.g. do I need to transpose an object?) or do the default parameters of tf-idf counts differ accross the packages?</p>
  
  <pre><code>library(tm)
  library(tidyverse) 
  library(quanteda)
  df &lt;- as.data.frame(cbind(doc = c("doc1", "doc2"), text = c("the quick brown fox jumps over the lazy dog", "The quick brown foxy ox jumps over the lazy god")), stringsAsFactors = F)
  
  df.count1 &lt;- df %&gt;% unnest_tokens(word, text) %&gt;% 
    count(doc, word) %&gt;% 
    bind_tf_idf(word, doc, n) %&gt;% 
    select(doc, word, tf_idf) %&gt;% 
    spread(word, tf_idf, fill = 0) 
  
  df.count2 &lt;- df %&gt;% unnest_tokens(word, text) %&gt;% 
    count(doc, word) %&gt;% 
    cast_dtm(document = doc,term = word, value = n, weighting = weightTfIdf) %&gt;% 
    as.matrix() %&gt;% as.data.frame()
  
  df.count3 &lt;- df %&gt;% unnest_tokens(word, text) %&gt;% 
    count(doc, word) %&gt;% 
    cast_dfm(document = doc,term = word, value = n) %&gt;% 
    dfm_tfidf() %&gt;% as.data.frame()
  
     &gt; df.count1
  # A tibble: 2 x 12
    doc   brown    dog    fox   foxy    god jumps  lazy  over     ox quick   the
    &lt;chr&gt; &lt;dbl&gt;  &lt;dbl&gt;  &lt;dbl&gt;  &lt;dbl&gt;  &lt;dbl&gt; &lt;dbl&gt; &lt;dbl&gt; &lt;dbl&gt;  &lt;dbl&gt; &lt;dbl&gt; &lt;dbl&gt;
  1 doc1      0 0.0770 0.0770 0      0          0     0     0 0          0     0
  2 doc2      0 0      0      0.0693 0.0693     0     0     0 0.0693     0     0
  
  &gt; df.count2
       brown       dog       fox jumps lazy over quick the foxy god  ox
  doc1     0 0.1111111 0.1111111     0    0    0     0   0  0.0 0.0 0.0
  doc2     0 0.0000000 0.0000000     0    0    0     0   0  0.1 0.1 0.1
  
  &gt; df.count3
       brown     dog     fox jumps lazy over quick the    foxy     god      ox
  doc1     0 0.30103 0.30103     0    0    0     0   0 0.00000 0.00000 0.00000
  doc2     0 0.00000 0.00000     0    0    0     0   0 0.30103 0.30103 0.30103
  </code></pre>