我看到了,但我不相信。 R 中的合法名称、管道操作和点
I see it, but I don't believe it. Legal names in R, piping operations, and the dot
在尝试理解 Win Vector 博客中描述的基础 R "Bizarro pipe" 时,我确认简单的示例在 R 中产生类似管道的行为,而没有安装包。例如:
> 2 ->.; exp(.)
[1] 7.389056
我发现点在plyr和magrittr中用作运算符。我花了几个小时在 base R 中寻找我能想到的点运算符的每个同义词,使用我知道的每个帮助工具;我什至 运行 进行了一些荒谬的正则表达式搜索。最后,无奈之下,我尝试了这个:
>. <- 27
>.
[1] 27
到目前为止,我未能证实一个裸点(其名称中甚至没有 ` `)是 R 中的有效变量名。但我仍然希望这只是某些人的副作用更明智的行为,记录在某处。
是吗?如果是,在哪里?
我承认,在它首次出现在 Win Vector 博客中时,运行作者将其视为一个笑话。
.
可以用作有效的对象名称(语法上有效的名称)并记录在此处:
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 dot not followed by a number."
在尝试理解 Win Vector 博客中描述的基础 R "Bizarro pipe" 时,我确认简单的示例在 R 中产生类似管道的行为,而没有安装包。例如:
> 2 ->.; exp(.)
[1] 7.389056
我发现点在plyr和magrittr中用作运算符。我花了几个小时在 base R 中寻找我能想到的点运算符的每个同义词,使用我知道的每个帮助工具;我什至 运行 进行了一些荒谬的正则表达式搜索。最后,无奈之下,我尝试了这个:
>. <- 27
>.
[1] 27
到目前为止,我未能证实一个裸点(其名称中甚至没有 ` `)是 R 中的有效变量名。但我仍然希望这只是某些人的副作用更明智的行为,记录在某处。
是吗?如果是,在哪里?
我承认,在它首次出现在 Win Vector 博客中时,运行作者将其视为一个笑话。
.
可以用作有效的对象名称(语法上有效的名称)并记录在此处:
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 dot not followed by a number."