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")

gaborcsardi/spark documentation built on July 26, 2017, 10:09 a.m.