[英]R chain operator usage
I understood that in R
we can create special function by using chain operator, but how can I know the function implementation/code for the chain operator? 我了解在
R
我们可以使用链运算符来创建特殊函数,但是我如何知道链运算符的函数实现/代码?
If I want to find out source for a function, I use > functionname
如果要查找函数的来源,请使用
> functionname
But when I tried to find source code for operator > "%*%"
it didn't print anything. 但是,当我尝试查找运算符
> "%*%"
源代码时,它没有显示任何内容。 Could someone please help me how I can find out source code for above chain operator? 有人可以帮我如何找到上述连锁经营者的源代码吗?
Assuming you are talking about the pipe operator, you need to have the package magrittr
loaded or dplyr
loaded using library
. 假设您在谈论管道运算符,则需要使用
library
加载magrittr
或dplyr
软件包。 Then you need to use backticks to access the function definition: 然后,您需要使用反引号来访问函数定义:
library(dplyr)
`%>%`
which gives 这使
function (lhs, rhs) {
lhs <- substitute(lhs)
rhs <- substitute(rhs)
if (is.call(rhs) && identical(rhs[[1]], quote(`(`)))
rhs <- eval(rhs, parent.frame(), parent.frame())
...
The reason for this is explained here Function name in single quotation marks in R R的功能名称在R中用单引号引起来
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.