sparse_left: Check How many Words are Left under Certain Sparse Values

Description Usage Arguments Examples

View source: R/sparse_left.R

Description

This function does not really remove sparse words (which is what tm::removeSparseTerms does); rather, it only shows how many words are left when you specify some sparse values. See Examples.

Usage

1
sparse_left(x, sparse)

Arguments

x

a DocumentTermMatrix or TermDocumentMatrix object.

sparse

a numeric vector with elements >= 0 and <= 1.

Examples

1
2
3
4
5
6
7
8
9
x <- c(
  "Hello, what do you want to drink?", 
  "drink a bottle of milk", 
  "drink a cup of coffee", 
  "drink some water")
dtm <- corp_or_dtm(x, from = "v", type = "dtm")
y <- sparse_left(dtm, seq(0, 1, 0.1))
# Then you can use plot(sort(y, decreasing = TRUE), type = "b") to 
# see which sparse value is proper.

chinese.misc documentation built on Sept. 13, 2020, 5:13 p.m.