wordcount: Word Count

Description Usage Arguments Author(s) See Also Examples

View source: R/wordcount.R

Description

The function takes a text file or text string and outputs a barplot of the most frequently occuring words.

Usage

1
wordcount(file = "", n, decreasing = TRUE, text)

Arguments

file

A text file whose location is interpreted relative to the current working directory (given by getwd). Can be left blank, in which case the text must be inputted as the argument text.

n

The number of words to show in the barplot. Should be an integer greater than 0 and less than the number of unique words in the text. For example, if n=5, then the barplot will show the 5 most frequently occuring words.

decreasing

If TRUE (the default), the words in the barplot will show from most frequent on the left to least frequent on the right. If FALSE, the most frequently occuring word will be on the right hand side of the barplot.

text

If you wish to enter text as an inline argument rather than as a file on your computer, you can enter your text as this argument and leave file blank.

Author(s)

Jonathan Schwartz

See Also

scan, barplot

Examples

1
2
3
4
5
6
myfile <- file.path(tempdir(), "wordcounttest.txt")
write("Four four four four. Three three three. Two two. One.",file=myfile )
wordcount(myfile ,4)

##or text can be entered inline
wordcount(text="Four four four four. Three three three. Two two. One.",n=4)

handyplots documentation built on May 2, 2019, 6:12 a.m.