Skip to contents

Also used internally by the [-operator for tf data (see ?tfbrackets) to evaluate object, see examples.

Usage

tf_evaluate(object, arg, ...)

# S3 method for default
tf_evaluate(object, arg, ...)

# S3 method for tfd
tf_evaluate(object, arg, evaluator = tf_evaluator(object), ...)

# S3 method for tfb
tf_evaluate(object, arg, ...)

Arguments

object

a tf, or a data.frame-like object with tf columns.

arg

optional evaluation grid (vector or list of vectors). Defaults to tf_arg(object), implicitly.

...

not used

evaluator

optional. The function to use for inter/extrapolating the tfd. Defaults to tf_evaluator(object). See e.g. tf_approx_linear() for details.

Value

A list of numeric vectors containing the function evaluations on arg.

See also

Other tidyfun inter/extrapolation functions: tf_approx_linear(), tf_interpolate()

Examples

f <- tf_rgp(3, arg = seq(0, 1, length.out = 11))
tf_evaluate(f) |> str()
#> List of 3
#>  $ 1: num [1:11] 0.264 0.717 0.802 0.655 0.5 ...
#>  $ 2: num [1:11] -2.121 -1.908 -1.396 -0.729 -0.262 ...
#>  $ 3: num [1:11] 0.291 -0.29 -0.444 -0.191 -0.105 ...
tf_evaluate(f, arg = 0.5) |> str()
#> List of 3
#>  $ 1: num 0.366
#>  $ 2: num -0.0252
#>  $ 3: num -0.61
# equivalent, as matrix:
f[, 0.5]
#>           0.5
#> 1  0.36585021
#> 2 -0.02516243
#> 3 -0.61012227
#> attr(,"arg")
#> [1] 0.5
new_grid <- seq(0, 1, length.out = 6)
tf_evaluate(f, arg = new_grid) |> str()
#> List of 3
#>  $ 1: num [1:6] 0.264 0.802 0.5 0.104 -0.144 ...
#>  $ 2: num [1:6] -2.1205 -1.3965 -0.2621 0.0976 0.9949 ...
#>  $ 3: num [1:6] 0.291 -0.444 -0.105 -0.962 0.55 ...
# equivalent, as matrix:
f[, new_grid]
#>            0        0.2        0.4         0.6        0.8         1
#> 1  0.2641399  0.8016938  0.5003438  0.10448947 -0.1438695 0.1386855
#> 2 -2.1205464 -1.3964857 -0.2620896  0.09757397  0.9949393 1.3542389
#> 3  0.2909722 -0.4444448 -0.1050264 -0.96190135  0.5496152 2.1038015
#> attr(,"arg")
#> [1] 0.0 0.2 0.4 0.6 0.8 1.0