将数据框通过管道传递给函数,该函数的参数通过管道传递点 [英] Pipe a data frame to a function whose argument pipes a dot
本文介绍了将数据框通过管道传递给函数,该函数的参数通过管道传递点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将数据帧通过管道传递给其参数通过管道传递点的函数?
How can one pipe a data frame to a function whose argument pipes a dot?
mpg %>% rbind(., . %>% rev())
rep中的错误(xi,length.out = nvar):尝试复制类型为'closure'的
对象
Error in rep(xi, length.out = nvar) : attempt to replicate an object of type 'closure'
另一个示例:
mpg %>%
{
. %>% arrange(manufacturer)
}
功能具有以下成分的序列:
Functional sequence with the following components:
- arrange(。,制造商)
使用'functions'提取单个函数。
Use 'functions' to extract the individual functions.
推荐答案
将圆点用圆括号括起来,例如(。)
:
Wrap the dot to be piped in parentheses like (.)
:
mpg %>% rbind(., (.) %>% rev())
,对于lambda函数:
Or, for lambda function:
mpg %>%
{
(.) %>% arrange(manufacturer)
}
这篇关于将数据框通过管道传递给函数,该函数的参数通过管道传递点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文