as.data.frame.yamlet: Coerce Yamlet to Data Frame

View source: R/data.frame.R

as.data.frame.yamletR Documentation

Coerce Yamlet to Data Frame

Description

Coerces yamlet to data.frame. Columns are constructed in the order that attributes are encountered, beginning with top-level 'item' (default). Cell contents are calculated using getOption('yamlet_cell_value', yamlet::cell_value) to which is passed the cell-specific metadata as well as sep and def.

Usage

## S3 method for class 'yamlet'
as.data.frame(
  x,
  row.names = "item",
  optional = FALSE,
  sep = "\n",
  def = ": ",
  ...
)

Arguments

x

yamlet; see decorations and read_yamlet

row.names

a name for a column to hold top-level names, or NULL to represent these as row.names

optional

if TRUE and row.names is NULL, row.names will not be set

sep

separator for multiple items within an attribute

def

definition string: separator between items and their (preceding) names, if any

...

ignored

Value

data.frame

Examples


library(magrittr)

file <- system.file(package = 'yamlet', 'extdata','quinidine.yaml')
file %>% read_yamlet %>% explicit_guide %>% as.data.frame
file <- system.file(package = 'yamlet', 'extdata','phenobarb.csv')

# phenobarb.yaml has conditional metadata that benefits
# from interpretation in the context of the data itself.
# thus, we
# * read the whole 'decorated' object (not just yaml),
# * resolve the 'guide' ambiguity,
# extract the best-guess decorations, and
# convert to data.frame.

file %>% io_csv %>% resolve %>% decorations %>% as.data.frame


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