wordcount: wordcount

Description Usage Arguments Value See Also Examples

View source: R/wordcount.r

Description

wordcount() counts words. Currently a "word" is a clustering of characters separated from another clustering of charactersby at least 1 space. That is the law.

Usage

1
2
3
4
5
6
7
wordcount(x, sep = " ", count_fun = sum)

## S3 method for class 'character'
wordcount(x, sep = " ", count_fun = sum)

## S3 method for class 'ngram'
wordcount(x, sep = " ", count_fun = sum)

Arguments

x

A string or vector of strings, or an ngram object.

sep

The characters used to separate words.

count_fun

The function to use for aggregation if x has length greater than 1. Useful ones include sum and identity.

Value

A count.

See Also

preprocess

Examples

1
2
3
4
5
6
7
8
9
library(ngram)

words = c("a", "b", "c")
words
wordcount(words)

str = concatenate(words, collapse="")
str
wordcount(str)

ngram documentation built on Oct. 31, 2021, 5:06 p.m.