【问题标题】:Table1() Descriptive Statistics in RTable1() R 中的描述性统计
【发布时间】:2020-07-07 23:43:22
【问题描述】:

是否有任何 table1 用户知道如何按频率降序对表进行排序?附表中的例子你知道如何排序到 14、11、7 吗?

library(table1)
mtcars$cyl <- as.factor(mtcars$cyl)
table1(~mtcars$cyl, data = mtcars)

【问题讨论】:

    标签: r charts statistics


    【解决方案1】:

    一种方法是根据cyl 的频率排列因子水平。

    mtcars$cyl <- factor(mtcars$cyl, levels = as.integer(names(sort(table(mtcars$cyl),
                                      decreasing = TRUE))))
    table1::table1(~cyl, data = mtcars)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-12-22
      • 2018-10-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-08
      • 2022-08-06
      相关资源
      最近更新 更多