Read a YAML document from a file and create an R object from it
either a character string naming a file or a connection open for writing
character string: if non-empty declares the
encoding used on a file (not a connection) so the character data can
be re-encoded. See
character string: if
a label to prepend to error messages (see Details).
arguments to pass to
This function is a convenient wrapper for
yaml.load and is a
nicer alternative to
You can specify a label to be prepended to error messages via the
error.label argument. If
error.label is missing,
read_yaml will make an educated guess for the value of
error.label by either using the specified filename (when
is a character vector) or using the description of the supplied connection
object (via the
summary function). If
text is used, the
default value of
error.label will be
If the root YAML object is a map, a named list or list with an attribute of 'keys' is returned. If the root object is a sequence, a list or vector is returned, depending on the contents of the sequence. A vector of length 1 is returned for single objects.
Jeremy Stephens <firstname.lastname@example.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
## Not run: # reading from a file connection filename <- tempfile() cat("test: data\n", file = filename) con <- file(filename, "r") read_yaml(con) close(con) # using a filename to specify input file read_yaml(filename) ## End(Not run) # reading from a character vector read_yaml(text="- hey\n- hi\n- hello")
$test  "data" $test  "data"  "hey" "hi" "hello"
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.