sparse_left {chinese.misc}R Documentation

Check How many Words are Left under Certain Sparse Values

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

sparse_left(x, sparse)

Arguments

x

a DocumentTermMatrix or TermDocumentMatrix object.

sparse

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

Examples

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.

[Package chinese.misc version 0.2.3 Index]