File: gvisWordTree.Rd

package info (click to toggle)
r-cran-googlevis 0.7.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,404 kB
  • sloc: makefile: 5
file content (122 lines) | stat: -rw-r--r-- 3,882 bytes parent folder | download
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/gvisWordTree.R
\name{gvisWordTree}
\alias{gvisWordTree}
\title{Google Word Tree with R
\Sexpr{googleChartName <- "wordtree"}
\Sexpr{gvisChartName <- "gvisWordTree"}}
\usage{
gvisWordTree(
  data,
  textvar = "",
  sizevar = "",
  stylevar = "",
  idvar = "",
  parentvar = "",
  options = list(),
  method = "implicit",
  chartid
)
}
\arguments{
\item{data}{\code{data.frame} that contains the data to be visualised}

\item{textvar}{a string that refers to the column name in \code{data} that
contains the text to be used.}

\item{sizevar}{a string that refers to the column name in \code{data} that
contains the size of the words in the word tree.}

\item{stylevar}{a string that refers to the column name in \code{data} that
contains the stlye of the text. 
For no warning message in plot, should be called \code{<textvar>.style}.}

\item{idvar}{(only when format is explicit) a string that refers to the 
column name in \code{data} that contains the unique ID of the text.}

\item{parentvar}{(only when format is explicit) a string that refers to the 
column name in \code{data} that contains the ID of the parent of the text.}

\item{options}{list of configuration options, see:

% START DYNAMIC CONTENT

\Sexpr[results=rd]{gsub("CHARTNAME", 
googleChartName,
readLines(file.path(".", "inst",  "mansections", 
"GoogleChartToolsURLConfigOptions.txt")))}

 \Sexpr[results=rd]{paste(readLines(file.path(".", "inst", 
 "mansections", "gvisOptions.txt")))}}

\item{method}{a string to say whether the word tree is either:
\describe{
\item{\code{implicit}}{ - will weight and connect automatically, or} 
\item{\code{explicit}}{ - can specify weights and connections}
}}

\item{chartid}{character. If missing (default) a random chart id will be 
generated based on chart type and \code{\link{tempfile}}}
}
\value{
\Sexpr[results=rd]{paste(gvisChartName)} returns list 
of \code{\link{class}}
 \Sexpr[results=rd]{paste(readLines(file.path(".", "inst", 
 "mansections", "gvisOutputStructure.txt")))}
}
\description{
A word tree depicts multiple parallel sequences of words. It could be used to 
show which words most often follow or precede a target word 
(e.g., "Cats are...") or to show a hierarchy of terms (e.g., a decision tree).
}
\section{Warning}{

The word tree chart may be undergoing substantial revisions in 
future Google Charts releases.
}

\examples{
## Please note that by default the googleVis plot command
## will open a browser window and requires Internet
## connection to display the visualisation.

wt1 <- gvisWordTree(Cats, textvar = "Phrase")
plot(wt1)

Cats2 <- Cats
Cats2$Phrase.style <- ifelse(Cats$Sentiment >= 7, "green", 
                             ifelse(Cats$Sentiment <= 3, "red", "black"))
                             
wt2 <- gvisWordTree(Cats2, textvar = "Phrase", stylevar = "Phrase.style",
                    options = list(fontName = "Times-Roman",
                                   wordtree = "{word: 'cats'}",
                                   backgroundColor = "#cba"))
plot(wt2)

# Explicit word tree
exp.data <- data.frame(id = as.numeric(0:9),
                       label = letters[1:10],
                       parent = c(-1, 0, 0, 0, 2, 2, 4, 6, 1, 7),
                       size = c(10, 5, 3, 2, 2, 2, 1, 1, 5, 1),
                       stringsAsFactors = FALSE)

wt3 <- gvisWordTree(exp.data, idvar = "id", textvar = "label", 
                    parentvar = "parent", sizevar = "size",
                    options = list(wordtree = "{format: 'explicit'}"),
                    method = "explicit")
plot(wt3)

}
\references{
Google Chart Tools API: 
\Sexpr[results=rd]{gsub("CHARTNAME", 
googleChartName, 
readLines(file.path(".", "inst",  "mansections", 
"GoogleChartToolsURL.txt")))}

% END DYNAMIC CONTENT
}
\author{
Ashley Baldry
}
\keyword{iplot}