spark (version 2.0.0)

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

Description

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

Usage

# S3 method for default
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

Run this code
# NOT RUN {
## 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")
# }

Run the code above in your browser using DataCamp Workspace