Advertisement
Guest User

Untitled

a guest
Jan 24th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. txt <- c("peter likes red", "mary likes green", "bob likes blue")
  2.  
  3. voc <- c("peter", "mary", "bob", "red", "green", "blue")
  4.  
  5. c("peter red", "mary green", "bob blue")
  6.  
  7. foo <- VCorpus(VectorSource(txt))
  8. inspect(DocumentTermMatrix(foo, list(dictionary = voc)))
  9. Non-/sparse entries: 6/12
  10. Sparsity : 67%
  11. Maximal term length: 5
  12. Weighting : term frequency (tf)
  13.  
  14. Terms
  15. Docs blue bob green mary peter red
  16. 1 0 0 0 0 1 1
  17. 2 0 0 1 1 0 0
  18. 3 1 1 0 0 0 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement