Learn R Programming

smappR (version 0.5)

word.frequencies: Counts words in a string vector

Description

word.frequencies splits a string vector into words and returns a data frame with each unique word and how many times it was used.

Usage

word.frequencies(text, stopwords = NULL, verbose = TRUE, sparsity = 0.999)

Arguments

text
string or string vector, text from which words are counted
stopwords
Additional stopwords to be removed.
verbose
logical, default is TRUE, which generates some output to the R console with information.

Examples

Run this code
## Not run: 
# ## connect to the Mongo database
#  mongo <- mongo.create("SMAPP_HOST:PORT", db="DATABASE")
#  mongo.authenticate(mongo, username="USERNAME", password="PASSWORD", db="DATABASE")
#  set <- "DATABASE.COLLECTION"
# 
# ## extract text from all tweets in the database
#  tweets <- extract.tweets(set, fields="text")
# 
# ## count words
#  wordFreq <- word.frequencies(tweets$text)
# ## End(Not run)

Run the code above in your browser using DataLab