spark.default: Spark line of a numeric vector on the terminal

Description Usage Arguments Value See Also Examples

View source: R/sparklines.R

Description

For marking the minumum/maximum, the crayon package is needed.

Usage

1
2
3
## Default S3 method:
spark(data, width = c("data", "auto", "screen"),
  min = NULL, max = NULL, range = NULL, ...)

Arguments

data

The data to visualize. It can be a numeric vector, or anything that can be cut into intervals with cut. Infinite values in numeric data are ignored, and a black character is plotted instead of them.

width

The width (number of characters) of the output. ‘data’ means that it will match the length of the data. ‘screen’ means that it will be scaled to match the width of the screen. ‘auto’ means ‘data’ if the length of the data is not longer than the screen width, and ‘screen’ otherwise.

min

If not NULL, then a crayon style to mark the minimum value.

max

If not NULL, then a crayon style to mark the maximum value.

range

Numeric vector with two elements, the range for the sparklines. Defaults to the range of the data.

...

Not used, it is an error if given.

Value

Character scalar containing the spark line.

See Also

Other spark: spark.matrix, spark

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
## Annual number of Lynx trappings
spark(lynx)

## Scaling to shorter
spark(lynx, width = 40)

## Changing the range
spark(1:10)
spark(1:10, range = c(1, 100))

## Scaling to longer
spark(1:10, width = 40)

## Luteinizing Hormone in Blood Samples,
## in blue, if the terminal supports it
cat(crayon::blue(spark(lh)), "\n")

Example output

...._==<U+2588>*_....._==_......____....._==_....._=<U+2588>=.....____......_=*_......._==....._=<U+2588><U+2588>=_..._=====......__==_...__==
._<U+2588>_.__.._..=_.==.__._=.._=._<U+2588>__==..=__=
..__==*<U+2588><U+2588><U+2588>
..........
........________========****<U+2588><U+2588><U+2588><U+2588><U+2588><U+2588><U+2588><U+2588><U+2588><U+2588><U+2588>
====_.===___=_<U+2588><U+2588>===___=<U+2588>=__**=====__.._<U+2588><U+2588><U+2588><U+2588>=_<U+2588><U+2588>* 

spark documentation built on July 21, 2017, 1:02 a.m.