Learn R Programming

berryFunctions (version 1.11.0)

pretty2: Truncated pretty breakpoints

Description

pretty with no values outside of x range

Usage

pretty2(x, n = 5, force = FALSE, ...)

Arguments

x
object with numeric values
n
desired number of values in pretty. DEFAULT: 5
force
Must output lenght equal n exactly? DEFAULT: FALSE
...
all other arguments in pretty.

Details

calculates pretty(x), then removes the values that do not lie within range(x). If force=TRUE, range(x) is reduced step by step in a while loop until the condition is met. This is useful if you want exactly 2 labels on an axis. In order not to get stuck, the outer values are taken if there are more than n values within range(x).

See Also

pretty , logVals

Examples

Run this code

k <- c(135, 155, 120, 105, 140, 130, 190, 110)
range(k)
pretty(k)
pretty2(k)

pretty(c(0.2, 0.9), n=2)
pretty2(c(0.2, 0.9), n=2)
pretty2(c(0.2, 0.9), n=2, force=TRUE)

Run the code above in your browser using DataLab