to_specList.Rd
This function is for internal use, but has been exported in case it's useful for people working 'manually' with lists of justifications.
to_specList(x, types, type, idsRequired = TRUE, silent = TRUE)
x | The list to parse. |
---|---|
types | The class to assign to the specification
list (the |
type | The class to assign to each specification
(in addition to |
A list of classes c("justifierSpecList", types)
where
each element is a specification of class
c("justifierSpec", type)
.
### Specify an example text exampleFile <- system.file("extdata", "simple-example.jmd", package="justifier"); ### Show contents cat(readLines(exampleFile), sep="\n");#> This is an example of minutes that include #> a source, an assertion, and a justification. For example, in #> the meeting, we can discuss the assertion that sleep deprivation #> affects decision making. We could quickly enter this assertion in #> a machine-readable way in this manner: #> #> --- #> assertion: #> - #> id: assertion_SD_decision #> label: Sleep deprivation affects the decision making proces. #> source: #> id: source_Harrison #> --- #> #> Because it is important to refer to sources, we cite a source as well. #> We have maybe specified that source elsewhere, for example in the #> minutes of our last meeting. That specification may have looked #> like this: #> #> --- #> source: #> - #> id: source_Harrison #> label: "Harrison & Horne (2000) The impact of sleep deprivation on decision making: A review." #> xdoi: "doi:10.1037/1076-898x.6.3.236" #> type: "Journal article" #> --- #> #> We can now refer to these two specifications later on, for #> example to justify decisions we take.### Load it with yum::load_and_simplify() loadedMinutes <- yum::load_and_simplify(exampleFile); ### Show contents names(loadedMinutes);#> [1] "assertion" "source"#> [1] "list"### Convert to specification list res <- to_specList(loadedMinutes["assertion"], type="assertion", types="assertions"); ### Show classes class(res);#> [1] "justifierSpecList" "assertions"### Show original and parsed objects loadedMinutes["assertion"];#> $assertion #> $assertion$id #> [1] "assertion_SD_decision" #> #> $assertion$label #> [1] "Sleep deprivation affects the decision making proces." #> #> $assertion$source #> $assertion$source$id #> [1] "source_Harrison" #> #> #>res;#> $assertion_SD_decision #> $id #> [1] "assertion_SD_decision" #> #> $label #> [1] "Sleep deprivation affects the decision making proces." #> #> $source #> $source$id #> [1] "source_Harrison" #> #> #> attr(,"class") #> [1] "justifierSpec" "assertion" #> #> attr(,"class") #> [1] "justifierSpecList" "assertions"