adapt_seq is similar to seq except that instead of selecting points equally spaced along an interval, it selects points such that the values of a function applied at those points are (very) roughly equally spaced. This can be useful for sampling a function in such a way that it can be plotted more smoothly, for example.

adapt_seq(
  from,
  to,
  length.out = 200,
  f = function(x, ...) {
     1
 },
  args = list(),
  quiet = FALSE
)

Arguments

from

start of interval

to

end of interval

length.out

desired length of sequence

f

a function

args

arguments passed to f

quiet

suppress warnings about NaNs, etc.

Value

a numerical vector

Examples

adapt_seq(0, pi, 25, sin)
#>  [1] 0.0000000 0.1745329 0.3490659 0.4363323 0.5235988 0.6108652 0.6981317
#>  [8] 0.7853982 0.8726646 0.9599311 1.0471976 1.1344640 1.2217305 1.3089969
#> [15] 1.3962634 1.4835299 1.5707963 1.6580628 1.7453293 1.8325957 1.9198622
#> [22] 2.0071286 2.0943951 2.1816616 2.2689280 2.3561945 2.4434610 2.5307274
#> [29] 2.6179939 2.7052603 2.7925268 2.9670597 3.1415927