Learn R Programming

sparkline (version 2.0)

spk_chr: Character Version of Sparklines

Description

Create a character version ofinteractive sparklines for use with other 'htmlwidgets' or tags.

Usage

spk_chr(values, ..., width = 60, height = 20, elementId = NULL, renderSelector = NULL)

Arguments

values
vector of values to visualize
...
additional options passed to jquery.sparkline; see jquery.sparkline docs
width
height and width of sparkline htmlwidget specified in any valid CSS size unit.
height
height and width of sparkline htmlwidget specified in any valid CSS size unit.
elementId
string id as a valid CSS element id.
renderSelector
string as CSS selector to render in a DOM element other than the htmlwidget container

Examples

Run this code
## Not run: 
#   #spk_chr works well with dplyr summarise
#   
#   library(dplyr)
#   library(sparkline)
#   library(formattable)
#   
#   mtcars %>%
#     group_by(cyl) %>%
#     summarise(
#       hp = spk_chr(
#         hp, type="box",
#         chartRangeMin=0, chartRangeMax=max(mtcars$hp)
#       ),
#       mpg = spk_chr(
#         mpg, type="box",
#         chartRangeMin=0, chartRangeMax=max(mtcars$mpg)
#       )
#     ) %>%
#     formattable() %>%
#     formattable::as.htmlwidget() %>%
#     spk_add_deps()
# ## End(Not run)

Run the code above in your browser using DataLab