I could subset a single column with the following syntax for functions that return data.frame
or list
:
library(dplyr)
filter(mtcars, disp > 400)$mpg
# [1] 10.4 10.4 14.7
But this causes the following error when used in a pipe (%>%
):
mtcars %>% filter(disp > 400)$mpg
# Error in .$filter(disp > 400) :
# 3 arguments passed to '$' which requires 2
I would like to know why $
does not work when used in pipe like the above example.