round2reso: Round to defined resolution increment

View source: R/round2reso.R

round2resoR Documentation

Round to defined resolution increment

Description

round2res rounds a value to a given resolution (e.g. increments of 0.5) rather than the typical decimal place

Usage

round2reso(val, reso)

Arguments

val

Vector. The values to be rounded

reso

Numeric. The resolution or increment to use for rounding

Examples

set.seed(1)
n <- 10
x <- runif(n, min=0, max=20)
xr <- round2reso(x, 5) # rounded values to increments of 5
plot(x, t="n", ylim=c(0,20), pch=20)
abline(h=seq(0,20,5), col=8, lty=3)
points(x, col=1, pch=1)
points(xr, col=2, pch=20)
arrows(x0=seq(n), x1=seq(n), y0=x, y1=xr, length=0.1)


marchtaylor/sinkr documentation built on July 4, 2022, 5:48 p.m.