to_yamlet.numeric: Coerce Numeric to Yamlet Storage Format

View source: R/yamlet.R

to_yamlet.numericR Documentation

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 class 'numeric'
to_yamlet(x, ...)

Arguments

x

object

...

ignored

Value

length-one character

See Also

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

Examples

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))

yamlet documentation built on Oct. 6, 2023, 9:07 a.m.