如何使用R管道子集数据帧

如何使用R管道子集数据帧,r,tidyverse,pipeline,R,Tidyverse,Pipeline,我试图根据另一个数据帧中相应的列元素对数据帧进行子集划分/过滤。 这是我以前做的 df <- df1[df1$col1 %in% df2$col2,] df%列到行名称('col1') 但是,我不知道如何使用%%>%%在第一次操作中使用过滤器将这两个代码合并为一个 df1 %>% filter(col1 %in% df2$col2) %>% remove_rownames %>% column_to_rownames('col1') df1 %>% filte

我试图根据另一个数据帧中相应的列元素对数据帧进行子集划分/过滤。 这是我以前做的

df <- df1[df1$col1 %in% df2$col2,]
df%列到行名称('col1')

但是,我不知道如何使用
%%>%%

在第一次操作中使用过滤器将这两个代码合并为一个
df1 %>% filter(col1 %in% df2$col2) %>% remove_rownames %>% column_to_rownames('col1')
df1 %>% filter(col1 %in% df2$col2) %>% remove_rownames %>% column_to_rownames('col1')