Description Usage Arguments Details Value Author(s) Examples
This package includes functions to create wordsDictionary object for txt file, find frequency of target word in wordsDictionary and plot words' frequency.
1 2 3 4 5 6 7 | wordsDictionary(fileName, removeStopWords = TRUE)
getFrequency(object, ...)
plotDic(object, ...)
## S3 method for class 'wordsDictionary'
getFrequency(object, word, type = "frequency", ...)
## S3 method for class 'wordsDictionary'
plotDic(object, yType = "frequency", minFeq = 1, ...)
|
fileName |
An URL, indicating the location of the target txt file. |
removeStopWords |
Logical value, indicating whether to remove stop words in dictionary. The default valur is TRUE. |
object |
A wordsDictionary object. |
word |
A string, indicating target word you want to find in dictionary. |
type |
"frequency" or "ratio", indicating the type of return value. The default value is "frequency". |
yType |
"frequency" or "ratio", indicating the type of value in y axis. The default value is "frequency". |
minFeq |
A number, indicating the minimal frequency, which is used to select words above the frequency to be plotted. The default value is 1. |
... |
Addtional arrguments not used here. |
wordsDictionary
returns a list, you may use $ to access the element in a wordsDictionary object.
wordsDictionary |
returns a list. |
getFrequency
returns the frequency of the target word.
plotDic
draws a plot of the dictionary.
Mengjie Wang
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | # Read in sample txt file, "rf.txt". It is a brief description of Roger Federer copied from Wiki.
mytxtPath <- system.file("extdata", "rf.txt", package = "wordsDictionary")
# Create a wordsDictionary object.
myDictionary <- wordsDictionary(mytxtPath)
# Access the bagOfWords attribute, which is the unique word in this txt file.
myDictionary$bagOfWords
# Get the frequency of "roger" in txt file.
getFrequency(myDictionary, "roger")
# Get the ratio of "roger" in txt file.
getFrequency(myDictionary, "roger", "ratio")
# Plot the words whoes frequency is at least 3.
plotDic(myDictionary, minFeq = 3)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.