tf_spread: Spread a 'tf'-column into many columns representing the...

View source: R/tidyr.R

tf_spreadR Documentation

Spread a tf-column into many columns representing the function evaluations.

Description

Similar in spirit to tidyr::spread(), but does NOT shorten, just widens the data frame – a tf-column is spread out into many columns containing the functional measurements.

Usage

tf_spread(data, value, arg, sep = "_", interpolate = FALSE)

Arguments

data

a data frame with at least one tf-column

value

the name of the tf-column to 'spread'/evaluate. You can supply bare variable names etc., see the dplyr::select() documentation. Also works without this if there's only one tf in data, see examples.

arg

(Semi-)optional. A vector of arg-values on which to evaluate the functions. If not provided, uses the default args. Should be specified for tf_irreg, otherwise all observed gridpoint are used for every function.

sep

separating character used to create column names for the new columns, defaults to "_" for column names "<name of the tf>_<arg-value>". Set to NULL to get column names that only contain the arg-value.

interpolate

interpolate-argument for evaluating the functional data. Defaults to FALSE, i.e., tfds are not inter/extrapolated on unobserved arg-values.

Value

a wider dataframe with the tf-column spread out into many columns each containing the functional measurements for one arg-value.

See Also

Other tidyfun data wrangling functions: tf_evaluate.data.frame(), tf_gather(), tf_nest(), tf_unnest()

Examples

d <- dplyr::tibble(g = 1:3)
d$f <- tf_rgp(3, 11L)
tf_spread(d, f)
tf_spread(d, -g)
tf_spread(d)

fabian-s/tidyfun documentation built on April 14, 2025, 5:16 a.m.