Skip to contents

Flattening takes all justifications, assertions, and sources from their parents and returns a structured justifier object containing these elements in separate lists, with each occurrence replaced with a reference to the corresponding identifier.

Usage

flatten(x, ..., recursionLevel = 0, silent = justifier::opts$get("silent"))

# S3 method for multipleJustifierElements
flatten(x, ..., recursionLevel = 0, silent = justifier::opts$get("silent"))

# S3 method for singleJustifierElement
flatten(x, ..., recursionLevel = 0, silent = justifier::opts$get("silent"))

Arguments

x

The justifier object or objects.

...

Additional arguments are passed to the methods.

recursionLevel

The depth of the recursion

silent

Whether to be silent or chatty

Value

A flattened justifier object.

Examples

### Programmatically create a justification with two assertions
### but without sources
justifierJustification <-
  justifier::justify(
    "Icecream will make me feel less fit",
    assertion = c(
      justifier::assert('Icecream is rich in energy'),
      justifier::assert('Consuming high-energy foods makes me feel less fit')
    ),
    weight = -.5
  );

### Flatten it into a structures justifier object
structuredJustification <-
  justifier::flatten(
    justifierJustification
  );

### Check it
str(structuredJustification, 1);
#> List of 5
#>  $ sources       : list()
#>   ..- attr(*, "class")= chr [1:4] "justifier" "justifierStructured" "justifierSource" "list"
#>  $ assertions    :List of 2
#>   ..- attr(*, "class")= chr [1:4] "justifier" "justifierStructured" "justifierAssertion" "list"
#>  $ justifications:List of 1
#>   ..- attr(*, "class")= chr [1:4] "justifier" "justifierStructured" "justifierJustification" "list"
#>  $ decisions     : list()
#>   ..- attr(*, "class")= chr [1:4] "justifier" "justifierStructured" "justifierDecision" "list"
#>  $ justifier     : list()
#>   ..- attr(*, "class")= chr [1:4] "justifier" "justifierStructured" "justifierJustifier" "list"
#>  - attr(*, "class")= chr [1:3] "justifier" "justifierStructuredObject" "list"