R 在tidytext中对文档中的元素进行排序
正如您可以看到右侧的图例,我需要将其重新排序为1,2,3,…64,而不是1,10,11…,8。我的术语文档矩阵如下。 请告诉我如何重新排列代码R 在tidytext中对文档中的元素进行排序,r,ggplot2,rstudio,tidytext,R,Ggplot2,Rstudio,Tidytext,正如您可以看到右侧的图例,我需要将其重新排序为1,2,3,…64,而不是1,10,11…,8。我的术语文档矩阵如下。 请告诉我如何重新排列代码 A tibble: 4,530 x 5 document term count n total <chr> <chr> <dbl> <int> <dbl> 1 1 activ 1 1 109 2
A tibble: 4,530 x 5
document term count n total
<chr> <chr> <dbl> <int> <dbl>
1 1 activ 1 1 109
2 10 agencydebt 1 1 109
3 10 assess 1 1 109
4 11 avail 1 1 109
5 11 balanc 2 1 109
A tible:4530 x 5
文件条款总数
1活动1 109
2 10机构债务1 109
3 10评估1 109
4 11 1 109
5 11平衡2 1 109
打印前请尝试这一行:
df$document = factor(df$document, levels=sort(as.numeric(df$document)))
其中df是您的数据帧的名称。非常感谢Florian!太好了,很高兴我能帮忙。