Find the members in a list matching a member expression

MatchListMembers(object, member, enclos = "?", q = "'", ...)

Arguments

object

a list containing named elements.

member

a member expression. Member expressions are character strings denoting named elements in a list object (see examples).

enclos

a character string containing the special symbol '?'. This symbol is to be replaced by matching expressions. The result of this substitution can be anything but, usually would be a valid R expression. Default: "?".

q

a quote symbol, Default: "'".

...

additional arguments passed to grep. For example, these could be ignore.case=TRUE or perl=TRUE.

Value

a named character vector, with names corresponding to the matched member quoted expressions (using the argument q as a quote symbol), and values corresponding to the 'enclos-ed' expressions after substituting the '?'.

See also

Examples

model <- PCMBaseTestObjects$model_MixedGaussian_ab MatchListMembers(model, "Sigma_x", "diag(model?[,,1L])")
#> $'a'$'Sigma_x' $'b'$'Sigma_x' #> "diag(model$'a'$'Sigma_x'[,,1L])" "diag(model$'b'$'Sigma_x'[,,1L])"
MatchListMembers(model, "S.*_x", "diag(model?[,,1L])")
#> $'a'$'Sigma_x' $'a'$'Sigmae_x' #> "diag(model$'a'$'Sigma_x'[,,1L])" "diag(model$'a'$'Sigmae_x'[,,1L])" #> $'b'$'Sigma_x' $'b'$'Sigmae_x' #> "diag(model$'b'$'Sigma_x'[,,1L])" "diag(model$'b'$'Sigmae_x'[,,1L])"
MatchListMembers(model, "Sigma_x", "model?[,,1L][upper.tri(model?[,,1L])]")
#> $'a'$'Sigma_x' #> "model$'a'$'Sigma_x'[,,1L][upper.tri(model$'a'$'Sigma_x'[,,1L])]" #> $'b'$'Sigma_x' #> "model$'b'$'Sigma_x'[,,1L][upper.tri(model$'b'$'Sigma_x'[,,1L])]"
MatchListMembers(model, "a$Sigma_x", "model?[,,1L][upper.tri(model?[,,1L])]")
#> $'a'$'Sigma_x' #> "model$'a'$'Sigma_x'[,,1L][upper.tri(model$'a'$'Sigma_x'[,,1L])]"