sample_interval: Sample variables by interval

View source: R/ranges.R

sample_intervalR Documentation

Sample variables by interval

Description

Sample variables by interval

Usage

sample_interval(.data, pos, breaks, fun = mean, ...)

Arguments

.data

(data.frame) Variables to sample.

pos

(numeric)

breaks

(numeric) Sorted (weakly) increasingly.

fun

(function|character) Sampling function

...

Additional arguments passed to fun

Examples

df <- data.frame(
  t = as_time(0:9),
  x = 0:9,
  y = 10:19
)
breaks <- as_time(c(0,5,10))
sample_interval(df[, c("x", "y")], df$t, breaks, fun = mean, na.rm = TRUE)
sample_interval(df[, c("x", "y")], df$t, breaks, fun = max, na.rm = TRUE)

columbia-glacier/cgr documentation built on Jan. 17, 2024, 2:42 p.m.