Evaluate tfs, both inside or outside a data.frame

tf_evaluate(object, ..., arg)

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

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

# S3 method for data.frame
tf_evaluate(object, ..., arg)

Arguments

object

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

...

optional: a selection of tf-columns. If empty, all tf-variables in the data frame are selected. You can supply bare variable names, select all variables between x and z with x:z, exclude y with -y. For more options, see the dplyr::select() documentation.

arg

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

Value

For tf-objects, a list of numeric vectors containing the function evaluations. For dataframes, replaces tf-columns with list columns of smaller data.frames containing the functions' arguments (arg) and evaluations (value).

Details

The arg-argument of tf_evaluate.data.frame method can be a list of arg-vectors or -lists used as the arg argument for the tf_evaluate()-method for the respective tf-columns in object. ... is not used for a tf-object, but a second unnamed argument to these methods will be interpreted as arg.

See also

This is used internally by [.tf to evaluate object.

Examples

library(dplyr) a <- tf_rgp(3, arg = 7) b <- tf_rgp(3, arg = 7) d <- tibble(a = a, b = b) tf_evaluate(a) %>% str()
#> List of 3 #> $ : num [1:7] -0.965 -0.904 0.348 0.645 -0.118 ... #> $ : num [1:7] -1.452 -0.825 -0.166 0.604 0.849 ... #> $ : num [1:7] 1.898 1.48 0.925 1.244 0.509 ...
tf_evaluate(a, arg = .5) %>% str()
#> List of 3 #> $ : num 0.645 #> $ : num 0.604 #> $ : num 1.24
tf_evaluate(d) %>% glimpse()
#> Rows: 3 #> Columns: 2 #> $ a <list> [<tbl_df[7 x 2]>, <tbl_df[7 x 2]>, <tbl_df[7 x 2]>] #> $ b <list> [<tbl_df[7 x 2]>, <tbl_df[7 x 2]>, <tbl_df[7 x 2]>]
tf_evaluate(d, -b) %>% glimpse()
#> Rows: 3 #> Columns: 2 #> $ a <list> [<tbl_df[7 x 2]>, <tbl_df[7 x 2]>, <tbl_df[7 x 2]>] #> $ b <tfd_reg> [<-1.2648096, -1.5408094, -1.4777528, -0.9407457, -0.1984694, 0…
tf_evaluate(d, a) %>% glimpse()
#> Rows: 3 #> Columns: 2 #> $ a <list> [<tbl_df[7 x 2]>, <tbl_df[7 x 2]>, <tbl_df[7 x 2]>] #> $ b <tfd_reg> [<-1.2648096, -1.5408094, -1.4777528, -0.9407457, -0.1984694, 0…
grid <- seq(0, 1, l = 11) # <arg> must be specified as named argument! tf_evaluate(d, arg = grid) %>% glimpse()
#> Rows: 3 #> Columns: 2 #> $ a <list> [<tbl_df[11 x 2]>, <tbl_df[11 x 2]>, <tbl_df[11 x 2]>] #> $ b <list> [<tbl_df[11 x 2]>, <tbl_df[11 x 2]>, <tbl_df[11 x 2]>]