wordtree: wordtree

Description Usage Arguments Value See Also Examples

View source: R/functions.R

Description

This is a simple wrapper for google's awesome Wordtree function https://developers.google.com/chart/interactive/docs/gallery/wordtree. NOTE: You _do_ need to be online to use this package, although apparently no data is sent to servers, as per https://developers.google.com/chart/interactive/docs/gallery/wordtree#data-policy.

Usage

1
wordtree(text, targetWord, direction, Number_words, fileName)

Arguments

text

A vector of phrases or sentances that should be used for the wordnet. You can feed the raw inputs in, we will not use the entire sentance but will extract what we want using the 'Number_words' parameter. I DO throw out all punctuation, numbers and characters since what we're interested in is the words.

targetWord

This is the main word which should be the "root" of the tree

direction

This specifies in what direction the tree should "grow". To have the root word on the left, and the tree on the right, type "suffix". In a "prefix" word tree, the root is on the right, and in a "double" word tree, it's in the center.

Number_words

This specifies how many words you would like the "tree" to consist of, not including the root. IE, if we feed the wordtree two sentences, "I like the man known as Ike", and "Hey, what's up Ike?" and select 'Number_words' =2, then the sentances will be shortened to "known as Ike" and "what's up Ike"

fileName

If you would like the wordtree to be saved somewhere, then specify the filename here.

Value

returns an html file containing the wordtree.

See Also

str_extract

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
sample <- c("cats are better than dogs",
"cats eat kibble",
"cats are better than hamsters",
"cats are awesome",
"cats are people too",
"cats eat mice",
"cats meowing",
"cats in the cradle",
"cats eat mice",
"cats in the cradle lyrics",
"cats eat kibble",
"cats for adoption",
"cats are family",
"cats eat mice",
"cats are better than kittens",
"cats are evil",
"cats are weird",
"cats eat mice")

wordtree(text=sample,targetWord = "cats",direction="suffix",Number_words = 4,fileName="thingie.html")
browseURL("thingie.html")

wordtree(text=sample,targetWord = "are",direction="double",Number_words=3,fileName="thingie.html")
browseURL("thingie.html")
## Not run: 
if(interactive()){
 #EXAMPLE1
 }

## End(Not run)

DataStrategist/wordTreeR documentation built on March 19, 2018, 4:10 a.m.