deparse
produces different results in R 3.4.4 and R 3.5. The NEWS suggests some defaults settings have changed but it is not clear to me how to ensure deparse
produces the same output in R 3.4.4 and R 3.5
R 3.4.4
> deparse(list(dec = 4L, b = "a"), control = "keepNA")
[1] "list(dec = 4, b = \"a\")"
R 3.5
> deparse(list(dec = 4L, b = "a"), control = "keepNA")
[1] "list(4, \"a\")"
EDIT:
Thanks to helpful suggestions by @HongOoi and @akrun the closest thing to a solution that will ensure the same result in both R 3.4.4 and R 3.5 seems to be:
dctrl <- if (getRversion() > "3.4.4") c("keepNA", "niceNames") else "keepNA"
deparse(list(dec = 4L, b = "a"), control = dctrl)
I haven't got R 3.5 installed, but per the NEWS file, you could try the showAttributes
and/or niceNames
arguments to deparse
:
These functions gain a new control option "niceNames" (see .deparseOpts()), which when set (as by default) also uses the (tag = value) syntax for atomic vectors. On the other hand, without deparse options "showAttributes" and "niceNames", names are no longer shown also for lists. as.character(list( c (one = 1))) now includes the name, as as.character(list(list(one = 1))) has always done.
We could use substitute
in R 3.5
to get the same result as in R 3.4.4
deparse(substitute(list(dec = 4L, b = "a")), control = "keepNA")
#[1] "list(dec = 4, b = \"a\")"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With