【发布时间】:2022-10-14 20:43:17
【问题描述】:
如何在不使用大括号的情况下使用管道将值传递给 filter 函数?
library(dplyr)
4 %>% {filter(mtcars, cyl == .)} # Works
4 %>% filter(mtcars, cyl == .) # Does not work
Error in UseMethod("filter") :
no applicable method for 'filter' applied to an object of class "c('double', 'numeric')"
【问题讨论】:
-
你的问题是什么?您发布的文字已经回答了标题中的问题。
-
我认为他想在没有花括号的情况下做到这一点。
-
@KonradRudolph确实,我希望它没有大括号。标题已编辑