as_yam.character: Coerce Character to Yam

View source: R/yamlet.R

as_yam.characterR Documentation

Coerce Character to Yam

Description

Coerces character to yam. Length-one character can be a filepath, otherwise treated as data. Proceeds by importing the data and determining the default keys.

Usage

## S3 method for class 'character'
as_yam(
  x,
  as.named.list,
  handlers = list(seq = parsimonious, map = function(x) lapply(x, unclass), str =
    function(x) {
     if (identical(x, "yamlet_NA_literal_")) {
         return("NA")
  
      }
     if (identical(x, "NA")) {
         return(NA_character_)
     }
    
    return(x)
 }),
  ...
)

Arguments

x

length-one filepath or actual data

as.named.list

enforced as TRUE

...

passed to read_yaml and yaml.load if supported

Value

a named list

See Also

Other yam: as.character.yam(), as_yam.yamlet(), as_yam()

Examples


# Read sample data from file.
file <- system.file(package = 'yamlet', 'extdata','quinidine.yaml')
file
as_yam(file)

# Read yamlet directly from character vector.
as_yam(c('ID:','TIME:'))

# Read from length-one character (same result).
as_yam('ID:\nTIME:')


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