Stream Chart
streamChart.Rd
Generates an Interactive Stream Chart.
Usage
streamChart(data,
x=NULL,
y=NULL,
group = NULL,
url.return = FALSE,
html.return = FALSE,
viewer = TRUE,
palette = NULL,
height=580,
div.name="chartdivstream")
Arguments
- data
A data.frame object containing data on the categories, the timeline or sequence of events and the quantity.
- x
The name of the variable in data containing the information relative to the timeline or the sequence of events.
- y
The name of the variable containing the quantities to be represented.
- group
The name of the variable indicating groups or aggregated categories.
- url.return
Logical. Indicates if the function should return the url address of the html file. The default is FALSE.
- html.return
Logical. Indicates if the function should return the html source code generated by the function. This option is useful for those wanting to save the results to a file. The default is FALSE.
- viewer
Logical. Indicates if the function should use RStudio viewer panel or the default browser to display the results. The default is TRUE.
- palette
A color palette to be employed in the chart. The default is NULL (Dark2 of RColorBrewer).
- height
The height of the html panel in pixels. The default is 580.
- div.name
Name of the div element employed to contain the graph. It is useful when you use the same type of graph multiple times in the same markdown page, for instance. The default is "chartdivstream".
Details
The function generates an interactive Stream Chart. It represents data along a central baseline. It is similar to an area chart, but splits the values using a central line of reference.
Value
A chart representing the evolution in time or sequence of a variable or the html source code generated.
Examples
if (FALSE) {
# Select the most salient representatives for
# the Vox party
ag <- spa.sessions[
spa.sessions$rep.name%in%
c("Abascal Conde, Santiago",
"Espinosa de los Monteros de Simón, Iván",
"Olona Choclán, Macarena",
"Ortega Smith-Molina, Francisco Javier"),]
# Create a variable of month for smoothing the data
ag$month <- substr(ag$session.date,3,7)
# Aggregate words by representative and month
ag <- aggregate(
list(words=ag$speech.tokens),
by=list(
month=ag$month,
rep=ag$rep.name,
party=ag$rep.party),
sum,
na.rm=T)
# Order the data by month
ag <- ag[order(ag$month),]
# Create the chart
streamChart(ag,
x="month",
y="words",
group = "rep")
}