Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

write_yaml

Write a YAML file


Description

Write the YAML representation of an R object to a file

Usage

write_yaml(x, file, fileEncoding = "UTF-8", ...)

Arguments

x

the object to be converted

file

either a character string naming a file or a connection open for writing

fileEncoding

character string: if non-empty declares the encoding to be used on a file (not a connection) so the character data can be re-encoded as they are written. See file.

...

arguments to as.yaml

Details

If file is a non-open connection, an attempt is made to open it and then close it after use.

This function is a convenient wrapper around as.yaml.

Author(s)

Jeremy Stephens <jeremy.f.stephens@vumc.org>

See Also

Examples

## Not run: 
  # writing to a file connection
  filename <- tempfile()
  con <- file(filename, "w")
  write_yaml(data.frame(a=1:10, b=letters[1:10], c=11:20), con)
  close(con)

  # using a filename to specify output file
  write_yaml(data.frame(a=1:10, b=letters[1:10], c=11:20), filename)

## End(Not run)

yaml

Methods to Convert R Data to YAML and Back

v2.2.1
BSD_3_clause + file LICENSE
Authors
Jeremy Stephens [aut, cre], Kirill Simonov [aut], Yihui Xie [ctb], Zhuoer Dong [ctb], Hadley Wickham [ctb], Jeffrey Horner [ctb], reikoch [ctb], Will Beasley [ctb], Brendan O'Connor [ctb], Gregory R. Warnes [ctb]
Initial release
2020-01-23

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.