Learn R Programming

yamlet (version 1.2.1)

as_yam.character: 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 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)
 }),
  ...
)

Value

a named list

Arguments

x

length-one filepath or actual data

as.named.list

enforced as TRUE

...

passed to read_yaml and yaml.load if supported

See Also

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

Examples

Run this code

# 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:')

Run the code above in your browser using DataLab