Why does tidyverse use .data sometimes, and then data other times?

An example that just tripped me up was tidyr::hoist using .data and other . prefixed arguments, but then tidyr::pivot_longer and tidy::pivot_wider using data and not . prefixed arguments.

.data is used to be explicit about a dataset, while data is refering to a dataset. Sort of more here: Chapter 12 Tidy evaluation | Mastering Shiny

From the tidyverse design guide

When using ... to create a data structure, or when passing ... to a user-supplied function, add a . prefix to all named arguments. This reduces (but does not eliminate) the chances of matching an argument at the wrong level.

E.g. in nest() the ... are used to create a data structure that's why it uses .names_sep instead of names_sep.
In the past unnest() used ... to create data structures and therefore the old arguments are prefixed with a .. But now ... is deprecated and you should use the cols argument. Therefore, the new argument are not prefixed.

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.