countWords {SentimentAnalysis} | R Documentation |
Count words
Description
Function counts the words in each document
Usage
countWords(
x,
aggregate = NULL,
removeStopwords = TRUE,
language = "english",
...
)
## S3 method for class 'Corpus'
countWords(
x,
aggregate = NULL,
removeStopwords = TRUE,
language = "english",
...
)
## S3 method for class 'character'
countWords(
x,
aggregate = NULL,
removeStopwords = TRUE,
language = "english",
...
)
## S3 method for class 'data.frame'
countWords(
x,
aggregate = NULL,
removeStopwords = TRUE,
language = "english",
...
)
## S3 method for class 'TermDocumentMatrix'
countWords(
x,
aggregate = NULL,
removeStopwords = TRUE,
language = "english",
...
)
## S3 method for class 'DocumentTermMatrix'
countWords(
x,
aggregate = NULL,
removeStopwords = TRUE,
language = "english",
...
)
Arguments
x |
A vector of characters, a |
aggregate |
A factor variable by which documents can be grouped. This helpful when joining e.g. news from the same day or move reviews by the same author |
removeStopwords |
Flag indicating whether to remove stopwords or not (default: yes) |
language |
Language used for preprocessing operations (default: English) |
... |
Additional parameters passed to function for e.g. preprocessing |
Value
Result is a matrix with word counts for each document across
Examples
documents <- c("This is a test", "an one more")
# count words (without stopwords)
countWords(documents)
# count all words (including stopwords)
countWords(documents, removeStopwords=FALSE)
[Package SentimentAnalysis version 1.3-5 Index]