Subsetting a lcModels list based on method arguments

# S3 method for class 'lcModels'
subset(x, subset, drop = FALSE, ...)

Arguments

x

The lcModels or list of lcModel to be subsetted.

subset

Logical expression based on the lcModel method arguments, indicating which lcModel objects to keep.

drop

Whether to return a lcModel object if the result is length 1.

...

Not used.

Value

A lcModels list with the subset of lcModel objects.

Functionality

See also

Examples

data(latrendData)
method <- lcMethodLMKM(Y ~ Time, id = "Id", time = "Time")

model1 <- latrend(method, latrendData, nClusters = 1)
model2 <- latrend(method, latrendData, nClusters = 2)
model3 <- latrend(method, latrendData, nClusters = 3)

rngMethod <- lcMethodRandom("Y", id = "Id", time = "Time")
rngModel <- latrend(rngMethod, latrendData)

models <- lcModels(model1, model2, model3, rngModel)

subset(models, nClusters > 1 & .method == 'lmkm')
#> List of 2 lcModels with
#>   .name .method nClusters
#> 1     1    lmkm         2
#> 2     2    lmkm         3