My question might sound stupid but I have noticed that .
and %
is often used in R
and to be frank I don't really know why it is used.
I have seen it in dplyr
(go here for an example) and data.table
(i.e. .SD
) but I am sure it must be used in other place as well.
Therefore, my question is:
- What does
.
mean? Is it some kind ofR
coding best practice nomenclature? (i.e._functionName
is often used injavascript
to indicate it is a private function). If yes, what's the rule? - Same question for
%
, which is also often used in R (i.e.%in%
,%>%
,...).
My guess always has been that .
and %
are a convenient way to quickly call function but the way data.table
uses .
does not follow this logic, which confuses me.