In trying to understand the base R "Bizarro pipe" as described in the Win Vector blog, I confirmed that simple examples produce pipelike behavior in R with no packages installed. For example:
> 2 ->.; exp(.)
[1] 7.389056
I found that the dot is used as an operator in plyr and magrittr. I spent a couple of hours looking in base R for every synonym I could think of for dot operator, with every help tool I knew of; I even ran some ridiculous regex searches. Finally, in desperation, I tried this:
>. <- 27
>.
[1] 27
So far, I have failed to disconfirm that a naked dot, without even a ` ` to its name, is a valid variable name in R. But I am still hoping that this is merely a side-effect from some more sensible behavior, documented somewhere.
Is it? And if so, where?
I acknowledge that in its first appearance in the Win Vector blog, the authors identified it as a joke.
.
can be used as a valid object name (a syntactically valid name) and documented here:
A syntactically valid name consists of letters, numbers and the dot or underline characters and starts with a letter or the dot not followed by a number." (from manual of
make.names
).
The single dot satisfies "the dot not followed by a number."
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