【问题标题】:Convert table to more html or csv table in r将表格转换为 r 中的更多 html 或 csv 表格
【发布时间】:2019-12-28 05:54:14
【问题描述】:

跟进之前的帖子seen here。我有这个代码创建的 tableone 包的输出

require(tableone)

sample_df <- structure(list(gender = structure(c(2L, 1L, 2L, 1L), .Label = c("female", 
"male"), class = "factor"), age = c(12, 65, 43, 22), treatment = structure(c(2L, 
1L, 2L, 1L), .Label = c("control", "treatment"), class = "factor"), 
    hypertension = structure(c(2L, 1L, 2L, 1L), .Label = c("No", 
    "Yes"), class = "factor"), diabetes = structure(c(2L, 1L, 
    2L, 1L), .Label = c("No", "Yes"), class = "factor")), class = "data.frame", row.names = c(NA, 
-4L))

vars <- names(sample_df)

tableOne <- CreateTableOne(vars = vars, 
                           strata = c("treatment"), 
                           data = sample_df, 
                           factorVars = c("gender","hypertension","diabetes"))

有没有办法将其转换为一个 html 表格,该表格可以导出为一个漂亮的单词或 csv 文件,具有来自stargazer 之类的表格质量?

【问题讨论】:

    标签: r html-table


    【解决方案1】:

    您是否尝试过制作降价文件?它具有极高的可定制性和灵活的导出格式,但也很容易立即使用。

    编辑:为了清楚起见,我在下面包含了一个屏幕截图。如果这不是您想要完成的,请告诉我。

    【讨论】:

    • “制作markdown文件”是什么意思?你的意思是在markdown中重做表格?目标是使用该包,因为即使存在大量变量,它也很灵活且易于使用
    • 哦,我明白你在说什么。是的,这不是一个糟糕的选择,但我更倾向于输出看起来不错的输出,例如 sjplot 包表
    猜你喜欢
    • 1970-01-01
    • 2014-05-03
    • 1970-01-01
    • 2011-02-07
    • 2017-11-03
    • 2010-11-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多