ropensci / targets

Function-oriented Make-like declarative workflows for R
https://docs.ropensci.org/targets/
Other
938 stars 73 forks source link

add "niceNames" and "showAttributes" to deparse options #1375

Closed wlandau closed 4 hours ago

wlandau commented 5 hours ago

Options "niceNames" and "showAttributes" have been part of .deparseOpts() since https://github.com/wch/r-source/blob/6363ed6d31e6b0637836728138f21fff5a126905/doc/NEWS.3.Rd#L1537-L1543. I think I was resistant to adding these initially because they seemed recent additions to R, but they have been around since R 3.5.0, which is the minimum version of targets. Adding them would improve the user experience for cases like https://github.com/ropensci/tarchetypes/issues/94.

wlandau commented 5 hours ago

To elaborate: targets currently does this:

deparse(structure(list(a = 1), class = "b"), control = c("keepNA", "keepInteger"))
#> [1] "list(1)"

I am proposing that it do this:

deparse(structure(list(a = 1), class = "b"), control = c("keepNA", "keepInteger", "niceNames", "showAttributes"))
#> [1] "structure(list(a = 1), class = \"b\")"

This will make tar_map() and tar_map_rep() easier to use.