Skip to contents

Similar to base::split, but working along the 6th, iter, dimension of any singular FLR object. The object is divided into as many objects as unique values in f, and returned as an FLlst-derived object, e.g. an FLQuants object when applied to an FLQuant.

Usage

# S4 method for class 'FLQuant,vector'
split(x, f)

# S4 method for class 'FLComp,vector'
split(x, f)

Arguments

x

The object to be split.

f

The vector of group names.

Value

An object of the corresponding plural class (FLQuants from FLQuant).

Author

Iago Mosqueira (WMR).

Examples

# FROM FLQuant to FLQuants
flq <- rlnorm(20, FLQuant(seq(0.1, 0.8, length=10)), 0.2)
split(flq, c(rep(1, 5), rep(2,15)))
#> $ 1 
#> An x of class "FLQuant"
#> iters:  5 
#> 
#> , , unit = unique, season = all, area = unique
#> 
#>      year
#> quant 1            2            3            4            5           
#>   all 1.47(0.1599) 1.18(0.3660) 1.22(0.3565) 1.28(0.0788) 1.50(0.3056)
#>      year
#> quant 6            7            8            9            10          
#>   all 1.42(0.4543) 1.80(0.5126) 1.46(0.1864) 2.08(0.2119) 1.98(0.6666)
#> 
#> units:  NA 
#> 
#> $ 2 
#> An x of class "FLQuant"
#> iters:  15 
#> 
#> , , unit = unique, season = all, area = unique
#> 
#>      year
#> quant 1             2             3             4             5            
#>   all 1.127(0.2068) 0.979(0.0847) 1.509(0.3653) 1.263(0.1581) 1.541(0.3109)
#>      year
#> quant 6             7             8             9             10           
#>   all 1.621(0.2897) 1.940(0.2817) 2.013(0.3607) 1.940(0.4493) 2.177(0.2441)
#> 
#> units:  NA 
#>