Learn R Programming

yamlet (version 1.2.1)

to_yamlet.numeric: Coerce Numeric to Yamlet Storage Format

Description

Coerces numeric to yamlet storage format. By default, numeric values would be processed as character. But character values with a leading dash are ordinarily quoted, since in character context a leading dash could be mistaken for a yaml metacharacter. In the case of a numeric value, however, we can be fairly certain that, despite appearances, the dash if any is actually a negative sign. This method intends to leave negative numerics unquoted, like their positive counterparts.

Usage

# S3 method for numeric
to_yamlet(x, ...)

Value

length-one character

Arguments

x

object

...

ignored

See Also

Other to_yamlet: to_yamlet(), to_yamlet.NULL(), to_yamlet.character(), to_yamlet.default(), to_yamlet.list(), to_yamlet.yamlet()

Examples

Run this code
library(magrittr)
 'a: [[d: [-1, 0, 1, 2]]]' %>% as_yamlet %>% to_yamlet
 to_yamlet(c(a = 4, b = 5.8))
 to_yamlet(list(a = 4, b = 5.8))
 to_yamlet(numeric(0))

Run the code above in your browser using DataLab