我想使用dplyr的GROUP_BY在當地的功能,例如:在一個函數中使用dplyr GROUP_BY
testFunction <- function(df, x) {
df %>%
group_by(x) %>%
summarize(mean.Petal.Width = mean(Petal.Width))
}
testFunction(iris, Species)
,我得到一個錯誤「...未知變量按組:X」 我我試了group_by_,它給了我一個整個數據集的總結。 有人有線索我怎麼能解決這個問題?
提前致謝!
很酷。這很有用,非常感謝。你有一個參考網址涵蓋了這個? – RoseS
@RoseS你可以查看[這裏](http://dplyr.tidyverse.org/articles/programming.html#quoting) – akrun