Travis-CI Build Status

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "README-"
)

ymlplyr

This package can be used to manipulate the YAML file headers.

Installation

You can install ymlplyr from github with:

# install.packages("remotes")
remotes::install_github("fmichonneau/ymlplyr")

Example

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)


fmichonneau/ymlplyr documentation built on May 4, 2019, 3:08 a.m.