1
我有一個數據框,我想通過某些標準的出現一定數量的過濾行。篩選器和計數沒有彙總數據幀
實施例:
yelp_tbl_asian %>% count(name) %>% filter(n > 10)
# A tibble: 16 x 2
name n
<chr> <int>
1 China Buffet 12
2 China Garden 12
3 China House 14
4 China Star 13
在該步驟之後,我想篩選/由其他標準編輯數據幀。
實施例:
yelp_tbl_asian %>% filter(rating > 3.5) %>% select(attributes) %>% dmap(unlist) %>% count(attributes) %>% arrange(desc(n))
# A tibble: 227 x 2
attributes n
<chr> <int>
1 RestaurantsTakeOut: True 3265
2 RestaurantsAttire: casual 3233
3 GoodForKids: True 2986
4 BusinessAcceptsCreditCards: True 2939
的問題是,第一步驟是消除從數據集中以下標準。所以在第一次過濾之後,第二步就不可能了。我想結合這兩個命令/步驟。
也許在filter()後面使用'left_join'將它與'name'上的原始df合併? – Sotos