knitr::opts_knit$set(root.dir = rprojroot::find_rstudio_root_file()) # Set WD to Root
here::i_am("dev/yaml.Rmd")
library(here)
library(yaml)

How to Read YAML

yaml.load("thai_font: Laksaman")

# If YAML field empty return `NULL`
yaml.load("thai_font: ")
suppressWarnings(read_yaml(here("dev/test_data/config.yml")))

Must suppress EOL warning from readLines(), unless specified n (which not have)

readLines(here("dev/test_data/config.yml"), warn = T)

How to Write YAML

yaml::write_yaml(list(thai_font = "Angsana New"), 
                 file = here("dev/test_data/config2.yml"))

yaml::read_yaml(here("dev/test_data/config2.yml"))


Lightbridge-KS/thaipdf documentation built on June 18, 2022, 6:58 a.m.