as_yamlet.character: Coerce Character To Yamlet Format

View source: R/yamlet.R

as_yamlet.characterR Documentation

Coerce Character To Yamlet Format

Description

Coerces character to yamlet format. Length-one character is understood as a file path if the file exists. Otherwise, it is treated as data. The file is a mapping of (nested) sequences, where map keys are data item names, and sequences represent data item attributes. Attributes may be named or anonymous.

Usage

## S3 method for class 'character'
as_yamlet(
  x,
  default_keys = getOption("yamlet_default_keys", list("label", "guide")),
  ...
)

Arguments

x

length-one filepath or actual data

default_keys

character: default keys for the first n anonymous members of each element

...

passed to as_yam.character and as_yamlet.yam

Details

If an attribute is anonymous, an attempt is made to name it using available defaults. A special item named '_keys' if present identifies a sequence of key names that over-ride default_keys. Attribute names are sought first in the explicit yaml, then in the special item named '_keys', then in the default_keys argument passed to as_yamlet, then in options()$yamlet_default_keys, then in the defaults for argument default_keys.

Value

yamlet: a named list with default keys applied

See Also

Other yamlet: [.yamlet(), as.character.yamlet(), as_yamlet.data.frame(), as_yamlet.list(), as_yamlet.yamlet(), as_yamlet.yam(), as_yamlet(), print.yamlet()

Examples

file <- system.file(package = 'yamlet', 'extdata','quinidine.yaml')
as_yamlet(file)
as_yamlet('ID: subject identifier')
as_yamlet(c('id: subject','amt: dose'))
as_yamlet(c('id: subject\namt: dose'))


yamlet documentation built on Oct. 6, 2023, 9:07 a.m.