These function extracts all YAML fragments from all files in a directory returning a list of character vectors containing the extracted fragments.
load_yaml_dir( path, recursive = TRUE, fileRegexes = c("^[^\\.]+.*$"), select = ".*", delimiterRegEx = "^---$", ignoreOddDelimiters = FALSE, encoding = "UTF-8", silent = TRUE )
path | The path containing the files. |
---|---|
recursive | Whether to also process subdirectories ( |
fileRegexes | A vector of regular expressions to match the files
against: only files matching one or more regular expressions in this
vector are processed. The default regex ( |
select | A vector of regular expressions specifying object names
to retain. The default ( |
delimiterRegEx | The regular expression used to locate YAML fragments. |
ignoreOddDelimiters | Whether to throw an error (FALSE) or delete the last delimiter (TRUE) if an odd number of delimiters is encountered. |
encoding | The encoding to use when calling |
silent | Whether to be silent ( |
A list of lists of objects.
These function extracts all YAML fragments from all files in a
directory and then calls yaml::yaml.load()
to parse them. It
then returns a list where each element is a list with the parsed
fragments in a file.
### First get the directory where 'yum' is installed yumDir <- system.file(package="yum"); ### Specify the path of some example files examplePath <- file.path(yumDir, "extdata"); ### Show files (should be three .dct files) list.files(examplePath);#> [1] "attitude.dct" "behavior.dct" "intention.dct"### Load these files yum::load_yaml_dir(path=examplePath);#> $`C:/Users/micro/AppData/Local/Temp/RtmpOme9Rr/temp_libpath4b4828e3ef5/yum/extdata/attitude.dct` #> [[1]] #> [[1]]$dct #> [[1]]$dct[[1]] #> [[1]]$dct[[1]]$id #> [1] "attitude_71vqm37n" #> #> [[1]]$dct[[1]]$label #> [1] "Attitude" #> #> [[1]]$dct[[1]]$date #> [1] "2018-12-13" #> #> [[1]]$dct[[1]]$source #> [[1]]$dct[[1]]$source$label #> [1] "Reasoned Action Approach" #> #> [[1]]$dct[[1]]$source$xdoi #> [1] "ISBN" #> #> #> [[1]]$dct[[1]]$def #> [[1]]$dct[[1]]$def$def #> [1] "A latent definition or tendency to respond with some degree of favorableness or unfavorableness to a psychological object." #> #> [[1]]$dct[[1]]$def$source #> [[1]]$dct[[1]]$def$source$spec #> [1] "p. 76" #> #> #> #> [[1]]$dct[[1]]$measure_dev #> [[1]]$dct[[1]]$measure_dev$instr #> [1] "Use semantic differentials with root \"For me, [TARGET BEHAVIOR] is ...\" and a bidimensional scale where the right-most anchor expresses a good, pleasant, beneficial, or interesting evaluation and the left-most anchor expresses the opposite bad/unpleasant/harmful/boring evaluation. The dimensions that are measured can differ depending on whatever is most relevant for the target behavior (e.g. dimensions such as unfavourable-favourable could also be used)." #> #> [[1]]$dct[[1]]$measure_dev$source #> [[1]]$dct[[1]]$measure_dev$source$spec #> [1] "p. 461" #> #> #> #> [[1]]$dct[[1]]$manipulate_dev #> [[1]]$dct[[1]]$manipulate_dev$instr #> NULL #> #> [[1]]$dct[[1]]$manipulate_dev$source #> NULL #> #> #> [[1]]$dct[[1]]$measure_code #> [[1]]$dct[[1]]$measure_code$instr #> [1] "Questionnaires that measure beneficial or pleasant aspects of the latent disposition or tendency to respond favourably versus unfavourably to [target behavior], for example using the semantic differentials good/bad, pleasant/unpleasant, wise/unwise." #> #> [[1]]$dct[[1]]$measure_code$source #> [1] "none" #> #> #> [[1]]$dct[[1]]$manipulate_code #> [[1]]$dct[[1]]$manipulate_code$instr #> NULL #> #> [[1]]$dct[[1]]$manipulate_code$source #> NULL #> #> #> [[1]]$dct[[1]]$aspect_code #> [[1]]$dct[[1]]$aspect_code$instruction #> [1] "Any global evaluation of the target behavior as a whole. Note that evaluations of specific aspects or consequences of the behavior relate to aspects of underlying constructs, not of attitude itself." #> #> #> [[1]]$dct[[1]]$parentId #> [1] "intention_71vr5q3q" #> #> [[1]]$dct[[1]]$alterId #> NULL #> #> #> #> #> [[2]] #> [[2]]$dct #> [[2]]$dct[[1]] #> [[2]]$dct[[1]]$id #> [1] "attitude_instrumental_xl678lqgp" #> #> [[2]]$dct[[1]]$label #> [1] "Instrumental Attitude" #> #> [[2]]$dct[[1]]$date #> [1] "2018-11-28" #> #> [[2]]$dct[[1]]$source #> [[2]]$dct[[1]]$source$label #> [1] "Reasoned Action Approach" #> #> [[2]]$dct[[1]]$source$id #> [1] "ISBN" #> #> #> [[2]]$dct[[1]]$def #> [[2]]$dct[[1]]$def$def #> [1] "Ins Att Def" #> #> [[2]]$dct[[1]]$def$id #> [1] "pp. 17-18" #> #> #> [[2]]$dct[[1]]$measure_dev #> [[2]]$dct[[1]]$measure_dev$instr #> [1] "Use semantic differentials with root \"For me, [TARGET BEHAVIOR] is ...\" and a bidimensional scale where the right-most anchor expresses a generally desirable instrumental state/goal and the left-most anchor expresses the opposite undesirable state/goal (e.g. \"unwise\" versus \"wise\")." #> #> #> [[2]]$dct[[1]]$measure_code #> [1] "Bla die bla." #> #> [[2]]$dct[[1]]$manipulate_dev #> [[2]]$dct[[1]]$manipulate_dev$instr #> [1] "Operationalisations that measure cognitive aspects of the latent disposition or tendency to respond favourably versus unfavourably to [target behavior], for example using the semantic differentials wise/unwise, good/bad." #> #> [[2]]$dct[[1]]$manipulate_dev$source #> [1] "none" #> #> #> [[2]]$dct[[1]]$aspect_code #> [[2]]$dct[[1]]$aspect_code$instr #> [1] "Expressions of benefits or advantages one perceives to be caused/obtained by engaging in the target behavior." #> #> [[2]]$dct[[1]]$aspect_code$source #> [1] "none" #> #> #> [[2]]$dct[[1]]$parentId #> [1] "attitude_71vqm37n" #> #> #> #> #> [[3]] #> [[3]]$dct #> [[3]]$dct[[1]] #> [[3]]$dct[[1]]$id #> [1] "attitude_experiential_xl678lqgn" #> #> [[3]]$dct[[1]]$label #> [1] "Experiential Attitude" #> #> [[3]]$dct[[1]]$date #> [1] "2018-11-28" #> #> [[3]]$dct[[1]]$source #> [[3]]$dct[[1]]$source$label #> [1] "Reasoned Action Approach" #> #> [[3]]$dct[[1]]$source$id #> [1] "ISBN" #> #> #> [[3]]$dct[[1]]$def #> [[3]]$dct[[1]]$def$def #> [1] "Exp Att Def" #> #> [[3]]$dct[[1]]$def$id #> [1] "pp. 15-16" #> #> #> [[3]]$dct[[1]]$measure_dev #> [[3]]$dct[[1]]$measure_dev$instr #> [1] "Use semantic differentials with root \"For me, [TARGET BEHAVIOR] is ...\" and a bidimensional scale where the right-most anchor expresses a pleasant affective state and the left-most anchor expresses the opposite unpleasant affective state (e.g. \"unpleasant\" versus \"pleasant\")." #> #> #> [[3]]$dct[[1]]$manipulate_dev #> [[3]]$dct[[1]]$manipulate_dev$instr #> [1] "hit one group of people with a stick and do nothing with the other group" #> #> #> [[3]]$dct[[1]]$measure_code #> [[3]]$dct[[1]]$measure_code$instr #> [1] "Operationalisations that measure affective aspects of the latent disposition or tendency to respond favourably versus unfavourably to [target behavior], for example using the semantic differentials pleasant/unpleasant, fun/boring." #> #> [[3]]$dct[[1]]$measure_code$source #> [1] "none" #> #> #> [[3]]$dct[[1]]$aspect_code #> [[3]]$dct[[1]]$aspect_code$instruction #> [1] "Expressions of feelings, emotions, or affective associations that one perceives to be caused by engaging in the target behavior." #> #> [[3]]$dct[[1]]$aspect_code$source #> [1] "none" #> #> #> [[3]]$dct[[1]]$parentId #> [1] "attitude_71vqm37n" #> #> [[3]]$dct[[1]]$alterId #> [1] "affective_expectancies" #> #> #> #> #> attr(,"class") #> [1] "yumFromFile" "list" #> #> $`C:/Users/micro/AppData/Local/Temp/RtmpOme9Rr/temp_libpath4b4828e3ef5/yum/extdata/behavior.dct` #> [[1]] #> [[1]]$dct #> [[1]]$dct[[1]] #> [[1]]$dct[[1]]$id #> [1] "behavior_xl67k7w8j" #> #> [[1]]$dct[[1]]$label #> [1] "Behavior" #> #> [[1]]$dct[[1]]$date #> [1] "2018-11-29" #> #> [[1]]$dct[[1]]$def #> [[1]]$dct[[1]]$def$def #> [1] "The target behavior" #> #> #> #> #> #> attr(,"class") #> [1] "yumFromFile" "list" #> #> $`C:/Users/micro/AppData/Local/Temp/RtmpOme9Rr/temp_libpath4b4828e3ef5/yum/extdata/intention.dct` #> [[1]] #> [[1]]$dct #> [[1]]$dct[[1]] #> [[1]]$dct[[1]]$id #> [1] "intention_71vr5q3q" #> #> [[1]]$dct[[1]]$label #> [1] "Intention" #> #> [[1]]$dct[[1]]$date #> [1] "2018-12-13" #> #> [[1]]$dct[[1]]$source #> [[1]]$dct[[1]]$source$name #> [1] "Reasoned Action Approach" #> #> [[1]]$dct[[1]]$source$id #> [1] "ISBN" #> #> #> [[1]]$dct[[1]]$def #> [[1]]$dct[[1]]$def$def #> [1] "The readiness to engage in the behavior, incorporating concepts such as willingness, behavioral expectation, and trying." #> #> [[1]]$dct[[1]]$def$id #> [1] "pp. 43" #> #> #> [[1]]$dct[[1]]$measure_dev #> [[1]]$dct[[1]]$measure_dev$Instr #> [1] "Use a likert scale to ask participants to what degree they intend to, are willing to, or plan to perform the target behavior." #> #> [[1]]$dct[[1]]$measure_dev$source #> [[1]]$dct[[1]]$measure_dev$source$spec #> [1] "p. 463" #> #> #> #> [[1]]$dct[[1]]$measure_code #> [[1]]$dct[[1]]$measure_code$instr #> [1] "Operationalisations that measure the degree to which [target population] have a deliberate (reasoned) plan/intention to engage in [target behavior]." #> #> #> [[1]]$dct[[1]]$aspect_code #> [[1]]$dct[[1]]$aspect_code$instr #> [1] "Any expressions that somebody has the intention, goal, or plan to perform a target behavior." #> #> #> [[1]]$dct[[1]]$parentId #> [1] "behavior_xl67k7w8j" #> #> [[1]]$dct[[1]]$alterId #> NULL #> #> #> #> #> attr(,"class") #> [1] "yumFromFile" "list" #> #> attr(,"class") #> [1] "yumFromDir" "list"