Extracts the attributes of objects nested in a list

extract_attr(x, str_attr)

Arguments

x

A list of objects with attributes or an object with an attribute

str_attr

A non-empty character string specifying which attribute is to be extracted

Value

Returns a list the length of x containing the specified attribute. If the attribute does not exist, returns NULL

Examples

design_opt_input <- list(rules = 4, actions = 5) design <- generate_designs(design_opt_input) extract_attr(design, "design_conditions")
#> [[1]] #> [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE #>
design_opt_input <- list(rules = 4, actions = 5, designs = 2) design <- generate_designs(design_opt_input) extract_attr(design, "design_conditions")
#> [[1]] #> [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE #> #> [[2]] #> [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE #>