skeleton_list: Create an empty recursive skeleton list.

Description Usage Arguments Value

View source: R/skeleton_list.R

Description

Sometimes it's convenient to store stuff in lists, i.e. if the stuff of interest contains attributes that might be needed in later functions. When these lists are recursive, this function can simplify the remaining code by creating a skeleton for the desired structure, based on the names to be used at the different levels.

Usage

1
2
skeleton_list(names_list, default_content = NULL,
  add_names_list_as_attribute = TRUE, compact = FALSE)

Arguments

names_list

A list-object containing vectors with the names to be used on the different levels (unique content required), where the rule is that the first component contains the names to be used at the top-level, and so on. If names_list is a vector, then an ordinary list will be created with names in accordance with those in the vector. Note that any names-attributes from names_list will be discarded in the construction of the new list. The list given to names_list must be a named list if the argument compact is TRUE.

default_content

Use this argument to specify a desired default for the "nodes" of the recursive list. The default selection for this argument is NULL.

add_names_list_as_attribute

Logic value, default TRUE, that will add the attribute names_list to the new list and assign names_list as its value.

compact

Logical value, default FALSE. This argument can be used to create a version of the result where the names are suppressed in exchange for an index-function (added as an attribute) that can find the correct level based on the names that normally would have been used. Note that names_list must have unique names when compact is given as TRUE. If names_list is a vector, then this argument will be ignored.

Value

A (recursive) list with names in accordance with those given in names_list, or with an index-function-attribute as described for the compact-argument.


LAJordanger/leanRcoding documentation built on Feb. 27, 2020, 4:42 p.m.