我有一个场景,在我的df中有几十万行,排列在8个组中,我希望能够通过Tab键通过前100个左右。我想用Unix的more做同样的事情。下面是一个使用tidytext包中的stop_words数据帧的类似的可重现示例。我想找出三组中字母表末尾的100个单词。我试过了:
> stop_words %>% group_by(lexicon) %>% arrange(desc(word)) %>% print(n=20)
# A tibble: 1,149 x 2
# Groups: lexicon [3]
word lexicon
<chr> <chr>
1 zero SMART
2 z SMART
3 yourselves SMART
4 yourselves snowball
5 yourself SMART
6 yourself snowball
7 yours SMART
8 yours snowball
9 yours onix
10 your SMART
11 your snowball
12 your onix
13 youngest onix
14 younger onix
15 young onix
16 you've SMART
17 you've snowball
18 you're SMART
19 you're snowball
20 you'll SMART
# ... with 1,129 more rows但它不能让我按空格键来浏览结果,它甚至不能给我每个组的前20名。如果我用top_n(20)替换管道中的最后一个命令,它仍然不会给我提供20个组,但我认为这是因为没有数字列作为排名的依据。
谁知道如何在我的管道末尾添加一个等同于more的东西?提前谢谢你。
发布于 2021-03-08 23:43:50
您可能想要使用slice_tail函数。
stop_words %>% group_by(lexicon) %>% slice_tail(n = 20)https://stackoverflow.com/questions/66532391
复制相似问题