yaml.load("- hey
- hi
- hello")
yaml.load("foo: 123
bar: 456")
yaml.load("- foo
- bar
- 3.14")
yaml.load("foo: bar
123: 456", as.named.list = FALSE)
yaml.load(readLines("foo.yml"))
# custom string-type handler
my.float.handler <- function(x) { as.numeric(x) + 123 }
yaml.load("123.456", handlers=list("float#fix"=my.float.handler))
# custom sequence handler
yaml.load("- 1
- 2
- 3", handlers=list(seq=function(x) { as.integer(x) + 3 }))
# custom map handler
yaml.load("foo: 123", handlers=list(map=function(x) { x$foo <- x$foo + 123; x }))
# handling custom types
yaml.load("!sqrt 555", handlers=list(sqrt=function(x) { sqrt(as.integer(x)) }))
yaml.load("!foo
- 1
- 2", handlers=list(foo=function(x) { as.integer(x) + 1 }))
yaml.load("!bar
one: 1
two: 2", handlers=list(foo=function(x) { x$one <- "one"; x }))
Run the code above in your browser using DataLab