r-yaml
r-yaml copied to clipboard
Convert yes/no to true/false
write_yaml() seems to be converting boolean values to yes/no. How can I leave this as it is. ie: true/false?
yaml 2.3.7
This is the #1 requested issue on this package. The root of the problem is the c library it's based on is an implementation of the YAML specification for 1.1 (1.2 is the current spec). Switching out the library is non-trivial. Please search the issues on this package as it's been discussed multiple times. Short answer: use a handler.
I can see that it has been discussed many times but I don't see a solution other than the word "handler". I don't see any documentation or any explanation for how handler works. Is there a reproducible example somewhere?
Here's an example:
yaml::as.yaml(c(TRUE, TRUE), handlers = list(logical = function(x) {
value <- ifelse(x, "true", "false")
structure(value, class = "verbatim")
}))
@cderv and @kevinushey please look over https://github.com/vubiostat/r-yaml/pull/133 and see if this fits your needs?
LGTM. I used almost the same function in quarto R package for handle this problem.
LGTM, but honestly I think it'd be better to just document this handler rather than provide and export it, just because the set of exported yaml functions is (probably intentionally) fairly small, and this function doesn't really fit with the other family of functions.