Skip to contents

Subset an object of class modeler

Usage

# S3 method for class 'modeler'
subset(x, id = NULL, ...)

Arguments

x

An object of class modeler, typically the result of calling modeler().

id

Unique identifier to filter a modeler object by a specific group. Default is NULL.

...

Additional parameters for future functionality.

Value

A modeler object.

Author

Johan Aparicio [aut]

Examples

library(flexFitR)
data(dt_potato)
mod <- dt_potato |>
  modeler(
    x = DAP,
    y = Canopy,
    grp = Plot,
    fn = "fn_logistic",
    parameters = c(L = 100, k = 4, t0 = 40),
    subset = 1:2
  )
print(mod)
#> 
#> Call:
#> Canopy ~ fn_logistic(DAP, L, k, t0) 
#> 
#> Residuals (`Standardized`):
#>     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
#> -1.90574 -0.48414 -0.02140 -0.19314  0.07097  1.17113 
#> 
#> Optimization Results `head()`:
#>  uid     L     k   t0  sse
#>    1  99.9 0.215 50.7 15.7
#>    2 100.0 0.198 48.3 22.4
#> 
#> Metrics:
#>  Groups      Timing Convergence Iterations
#>       2 1.3862 secs        100%  1345 (id)
#> 
mod_new <- subset(mod, id = 2)
print(mod_new)
#> 
#> Call:
#> Canopy ~ fn_logistic(DAP, L, k, t0) 
#> 
#> Residuals (`Standardized`):
#>     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
#> -1.53735 -0.60292  0.01037 -0.19574  0.07725  1.17113 
#> 
#> Optimization Results `head()`:
#>  uid   L     k   t0  sse
#>    2 100 0.198 48.3 22.4
#> 
#> Metrics:
#>  Groups      Timing Convergence Iterations
#>       1 1.3862 secs        100%  2102 (id)
#>