> inspect (tdm)
<<TermDocumentMatrix (terms: 56, documents: 6)>>
Non-/sparse entries: 67/269
Sparsity           : 80%
Maximal term length: 13
Weighting          : term frequency (tf)
Sample             :
            Docs
Terms        1 2 3 4 5 6
  accept     1 0 0 0 0 0
  depict     1 0 0 0 0 0
  fiction    2 0 0 1 1 0
  film       2 0 0 1 1 2
  fulli      1 0 0 0 0 0
  genr       1 1 1 0 0 1
  mainstream 1 0 0 0 0 0
  often      0 0 0 0 2 0
  scienc     2 0 0 1 2 0
  specul     1 0 0 0 1 0
> frq <- colSums (as.matrix (tdm))
> length (frq)
[1] 6
> inspect (frq)
Error in UseMethod("inspect", x) : 
  no applicable method for 'inspect' applied to an object of class "c('double', 'numeric')"
> head (frq)
 1  2  3  4  5  6 
16 15  5 14 13 10 
> freqTerm <- removeSparseTerms (tdm, 0.4)
> inspect (frqTerm)
Error in inspect(frqTerm) : object 'frqTerm' not found
> inspect (freqTerm)
<<TermDocumentMatrix (terms: 2, documents: 6)>>
Non-/sparse entries: 8/4
Sparsity           : 33%
Maximal term length: 4
Weighting          : term frequency (tf)
Sample             :
      Docs
Terms  1 2 3 4 5 6
  film 2 0 0 1 1 2
  genr 1 1 1 0 0 1
> freqTerm <- removeSparseTerms (tdm, 0.6)
> inspect (freqTerm)
<<TermDocumentMatrix (terms: 4, documents: 6)>>
Non-/sparse entries: 14/10
Sparsity           : 42%
Maximal term length: 7
Weighting          : term frequency (tf)
Sample             :
         Docs
Terms     1 2 3 4 5 6
  fiction 2 0 0 1 1 0
  film    2 0 0 1 1 2
  genr    1 1 1 0 0 1
  scienc  2 0 0 1 2 0
> findFreqTerms (tdm, lowfreq = 2)
[1] "fiction" "film"    "genr"    "scienc"  "specul"  "often"  
> findFreqTerms (tdm, lowfreq = 4)
[1] "fiction" "film"    "genr"    "scienc" 
> findFreqTerms (tdm, lowfreq = 6)
[1] "film"
> findFreqTerms (tdm, lowfreq = 1)
 [1] "accept"        "depict"        "fiction"       "film"         
 [5] "fulli"         "genr"          "mainstream"    "phenomena"    
 [9] "scienc"        "scienceba"     "scifi"         "specul"       
[13] "use"           "cinema"        "ear"           "effect"       
[17] "employ"        "exist"         "georg"         "meli"         
[21] "moon"          "photographi"   "silent"        "sinc"         
[25] "trick"         "trip"          "year"          "consist"      
[29] "lowbudget"     "main"          "movi"          "boxoff"       
[33] "brought"       "close"         "encount"       "hit"          
[37] "huge"          "increa"        "kind"          "star"         
[41] "third"         "war"           "element"       "includ"       
[45] "key"           "natur"         "often"         "support"      
[49] "technolog"     "blur"          "extraordinari" "gain"         
[53] "line"          "power"         "protagonist"   "superhero"    
> word_frq <- data.frame (word = names (frq), freq = frq)
> print (word_frq)
  word freq
1    1   16
2    2   15
3    3    5
4    4   14
5    5   13
6    6   10
> findAssocs (tdm, c("film","fiction"))
Error in is.numeric(corlimit) : 
  argument "corlimit" is missing, with no default
> findAssocs (tdm, c("film","fiction"), corlimit = 0.4)
$film
       accept        depict         fulli    mainstream     phenomena 
         0.55          0.55          0.55          0.55          0.55 
    scienceba         scifi           use          blur extraordinari 
         0.55          0.55          0.55          0.55          0.55 
         gain          line         power   protagonist     superhero 
         0.55          0.55          0.55          0.55          0.55 
       scienc        specul 
         0.45          0.43 

$fiction
    scienc     accept     depict      fulli mainstream  phenomena  scienceba 
      0.91       0.80       0.80       0.80       0.80       0.80       0.80 
     scifi        use     specul 
      0.80       0.80       0.79 

> inspect (TermDocumentMatrix (txt, list (dictionary = c ("film", "fiction"))))
<<TermDocumentMatrix (terms: 2, documents: 6)>>
Non-/sparse entries: 7/5
Sparsity           : 42%
Maximal term length: 7
Weighting          : term frequency (tf)
Sample             :
         Docs
Terms     1 2 3 4 5 6
  fiction 2 0 0 1 1 0
  film    2 0 0 1 1 2
> txt_tfidf <- TermDocumentMatrix (txt, control = list (weighting = weightingTfIdf))
Error in is.list(control) : object 'weightingTfIdf' not found
> txt_tfidf <- TermDocumentMatrix (txt, control = list (weighting = TfIdf))
Error in is.list(control) : object 'TfIdf' not found
> txt_tfidf <- TermDocumentMatrix (txt, control = list (weighting = weightTfIdf))
> inspect (txt_tfidf)
<<TermDocumentMatrix (terms: 56, documents: 6)>>
Non-/sparse entries: 67/269
Sparsity           : 80%
Maximal term length: 13
Weighting          : term frequency - inverse document frequency (normalized) (tf-idf)
Sample             :
               Docs
Terms                    1 2         3          4          5         6
  blur          0.00000000 0 0.0000000 0.00000000 0.00000000 0.2584963
  consist       0.00000000 0 0.5169925 0.00000000 0.00000000 0.0000000
  extraordinari 0.00000000 0 0.0000000 0.00000000 0.00000000 0.2584963
  fiction       0.12500000 0 0.0000000 0.07142857 0.07692308 0.0000000
  film          0.07312031 0 0.0000000 0.04178304 0.04499712 0.1169925
  lowbudget     0.00000000 0 0.5169925 0.00000000 0.00000000 0.0000000
  main          0.00000000 0 0.5169925 0.00000000 0.00000000 0.0000000
  movi          0.00000000 0 0.5169925 0.00000000 0.00000000 0.0000000
  often         0.00000000 0 0.0000000 0.00000000 0.39768654 0.0000000
  scienc        0.12500000 0 0.0000000 0.07142857 0.15384615 0.0000000
> 
