【问题标题】:Sort an element in a document in tidytext在tidytext中对文档中的元素进行排序
【发布时间】:2017-08-04 11:12:06
【问题描述】:

正如您在右侧看到的图例,我需要将其重新排序为 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        10 agencydebt     1     1   109
3        10     assess     1     1   109
4        11      avail     1     1   109
5        11     balanc     2     1   109

The image of my histogram is here.

【问题讨论】:

    标签: r ggplot2 rstudio tidytext


    【解决方案1】:

    在绘图前试试这条线:

    df$document = factor(df$document, levels=sort(as.numeric(df$document)))
    

    其中 df 是您的数据框的名称。

    【讨论】:

    • 非常感谢弗洛里安!
    • 太好了,很高兴我能帮上忙。
    猜你喜欢
    • 2015-11-06
    • 1970-01-01
    • 2015-05-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-18
    • 2011-01-02
    • 1970-01-01
    相关资源
    最近更新 更多