如何将数据帧传送到其参数传送点的函数?
mpg %>% rbind(., . %>% rev())
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(., manufacturer)
Use 'functions' to extract the individual functions.
最佳答案
将要通过管道传输的点括在括号中,例如 (.)
:
mpg %>% rbind(., (.) %>% rev())
或者,对于 lambda 函数:
mpg %>%
{
(.) %>% arrange(manufacturer)
}
关于r - 将数据框通过管道传递给一个函数,该函数的参数通过管道传递一个点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37757191/