gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 04:12:17 25 4
gpt4 key购买 nike

如何将数据帧传送到其参数传送点的函数?

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:

  1. arrange(., manufacturer)

Use 'functions' to extract the individual functions.

最佳答案

将要通过管道传输的点括在括号中,例如 (.):

mpg %>% rbind(., (.) %>% rev())

或者,对于 lambda 函数:

mpg %>%
{
(.) %>% arrange(manufacturer)
}

关于r - 将数据框通过管道传递给一个函数,该函数的参数通过管道传递一个点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37757191/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com