Extend range of variable limits while retaining a point of symmetricity

Share:

Description

This function serves as an alternative to the R function 'extendrange', when user wishes to conserve a point of symmetricity for the range. For example, this might be desired when the plot should be symmetric around the origin x=0, but that the sides need to extend beyond the actual range of values.

Usage

1
extendsymrange(x, r = range(x, na.rm = T), f = 0.05, sym = 0)

Arguments

x

Vector of values to compute the range for

r

The range of values

f

The factor by which the range is extended beyond the extremes

sym

The defined point of symmetricity

Value

A vector of 2 values for the lower and higher limit of the symmetric extended range

Author(s)

Teemu Daniel Laajala <teelaa@utu.fi>

See Also

extendrange

Examples

1
2
3
4
set.seed(1)
ex <- rnorm(10)+2

hist(ex, xlim=extendsymrange(ex, sym=0), breaks=100)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.