spread_seq: Spread sequence

Description Usage Arguments Examples

View source: R/seq_range.R

Description

Spread out the values of a numeric vector

Usage

1
2
spread_seq(x, f = 1.1, ..., node = c("midrange", "first", "last",
  "mean", "median", "min", "max"))

Arguments

x

a numeric vector

f

numeric or item matching a function. If numeric, a multiplicative factor applied to the distance between points, otherwise a function to be applied to differences

...

further arguments passed to f if matching a function

node

the location of x that will remain unchanged

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
x <- c(-1, 0, 2, NA, 4, 5, 6, 8, 9)

spread_seq(c(-1, 1))
spread_seq(x, 1.5, "midrange")
spread_seq(x, 1.5, "first")
spread_seq(x, 1.5, "last")
spread_seq(x, 1.5, "mean")
spread_seq(x, 1.5, "median")

spread_seq(c(3, 4, 1, 9, 6))
spread_seq(c(3, 4, 1, 9, 6), 2, "min")
spread_seq(c(3, 4, 1, 9, 6), 2, "max")

spread_seq(c(3, 4, 1, 9, 6), "/", 2)
spread_seq(c(3, 4, 1, 9, 6), 0.5)

y <- sort(c(3, 4, 1, 9, 6))
plot(y)
lines(spread_seq(y, "log1p"))

f <- function(x) sqrt(abs(x)*2)*sign(x)
y <- c(3, 4, 1, 9, 6)
plot(y)
lines(spread_seq(y, f=f))

AkselA/R-ymse documentation built on March 21, 2020, 9:52 a.m.