将数据框通过管道传递给函数,该函数的参数通过管道传递点

问题描述:

如何将数据帧通过管道传递给其参数通过管道传递点的函数?

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:


  1. 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)
  }