knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "README-" )
This package can be used to manipulate the YAML file headers.
You can install ymlplyr from github with:
# install.packages("remotes") remotes::install_github("fmichonneau/ymlplyr")
This is a basic example which shows you how to solve a common problem:
pet_yaml_file <- system.file("yaml_examples", "pets.yml", package="ymlplyr") cat(readLines(con = pet_yaml_file), sep="\n") ## Add elements example1 <- tempfile() yml_append(pet_yaml_file, list(pets = list(dogs = c("Milou", "Santa Claus"), cats = "Kitty", rat = "Ratatouille")), output = example1) cat(readLines(con = example1), sep = "\n") unlink(example1) ## Replace elements example2 <- tempfile() yml_replace(pet_yaml_file, list(pets = list(dogs = "Milou", cats = "Kitty")), output = example2) cat(readLines(con = example2), sep = "\n") unlink(example2) ## Remove elements example3 <- tempfile() yml_replace(pet_yaml_file, list(pets = list(dogs = NULL)), output = example3) cat(readLines(con = example3), sep = "\n") unlink(example3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.