Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Loading YAML in R without converting 'Yes' to True and 'No' to False

Tags:

r

yaml

How can I read the following string where 'Yes' are not converted to true

string <- "
a: 
 cc : dd
 dd : ee
b: 
 ee : Yes
 ff : 1
"

Now I get

yaml.load(string)

#$a
#$a$cc
#[1] "dd"
#$a$dd
#[1] "ee"
#
#$b
#$b$ee
#[1] TRUE
#$b$ff
#[1] 1
like image 885
imsc Avatar asked Oct 24 '25 10:10

imsc


1 Answers

You could use the identity function as a hanlder:

yaml.load(string, handlers = list("bool#yes" = identity))

which gives you:

$a
NULL

$cc
[1] "dd"

$dd
[1] "ee"

$b
NULL

$ee
[1] "Yes"

$ff
[1] 1
like image 131
johannes Avatar answered Oct 26 '25 01:10

johannes