Extract the method arguments as a list

# S3 method for lcMethod
as.list(x, ..., args = names(x), eval = TRUE, expand = FALSE, envir = NULL)

Arguments

x

The lcMethod object.

...

Additional arguments.

args

A character vector of argument names to select. Only available arguments are returned. Alternatively, a function or list of functions, whose formal arguments will be selected from the method.

eval

Whether to evaluate the arguments.

expand

Whether to return all method arguments when "..." is present among the requested argument names.

envir

The environment in which to evaluate the arguments. If NULL, the environment associated with the object is used. If not available, the parent.frame() is used.

Value

A list with the argument calls or evaluated results depending on the value for eval.

Examples

data(latrendData)
method <- lcMethodLMKM(Y ~ Time, id = "Id", time = "Time")
as.list(method)
#> $time
#> [1] "Time"
#> 
#> $id
#> [1] "Id"
#> 
#> $nClusters
#> [1] 2
#> 
#> $center
#> function (x, ...) 
#> {
#>     mean(x, ..., na.rm = TRUE)
#> }
#> <bytecode: 0x55be2c0a0a30>
#> <environment: namespace:latrend>
#> 
#> $standardize
#> function (x, center = TRUE, scale = TRUE) 
#> UseMethod("scale")
#> <bytecode: 0x55be2c0dc500>
#> <environment: namespace:base>
#> 
#> $method
#> [1] "qr"
#> 
#> $model
#> [1] TRUE
#> 
#> $y
#> [1] FALSE
#> 
#> $qr
#> [1] TRUE
#> 
#> $singular.ok
#> [1] TRUE
#> 
#> $contrasts
#> NULL
#> 
#> $iter.max
#> [1] 10
#> 
#> $nstart
#> [1] 1
#> 
#> $algorithm
#> [1] "Hartigan-Wong" "Lloyd"         "Forgy"         "MacQueen"     
#> 
#> $formula
#> Y ~ Time
#> <environment: 0x55be2c3b8ca0>
#> 

as.list(method, args = c("id", "time"))
#> $id
#> [1] "Id"
#> 
#> $time
#> [1] "Time"
#> 

if (require("kml")) {
  method <- lcMethodKML("Y", id = "Id", time = "Time")
  as.list(method)

  # select arguments used by kml()
  as.list(method, args = kml::kml)

  # select arguments used by either kml() or parALGO()
  as.list(method, args = c(kml::kml, kml::parALGO))
}
#> Loading required package: kml
#> Loading required package: clv
#> Loading required package: cluster
#> Loading required package: class
#> Loading required package: longitudinalData
#> Loading required package: rgl
#> Warning: RGL: unable to open X11 display
#> Warning: 'rgl.init' failed, running with 'rgl.useNULL = TRUE'.
#> Loading required package: misc3d
#> Warning: no DISPLAY variable so Tk is not available
#> 
#> Attaching package: ‘longitudinalData’
#> The following object is masked from ‘package:latrend’:
#> 
#>     meanNA
#> $nbRedrawing
#> [1] 20
#> 
#> $maxIt
#> [1] 200
#> 
#> $imputationMethod
#> [1] "copyMean"
#> 
#> $distanceName
#> [1] "euclidean"
#> 
#> $power
#> [1] 2
#> 
#> $distance
#> function(){}
#> <environment: 0x55be2dbe9bf8>
#> 
#> $centerMethod
#> function(x){mean(x,na.rm=TRUE)}
#> <bytecode: 0x55be2afd27f0>
#> <environment: namespace:longitudinalData>
#> 
#> $startingCond
#> [1] "nearlyAll"
#> 
#> $nbCriterion
#> [1] 1000
#> 
#> $scale
#> [1] TRUE
#>