Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 如何保存expss包的输出?_R_Save_Output_Expss - Fatal编程技术网

R 如何保存expss包的输出?

R 如何保存expss包的输出?,r,save,output,expss,R,Save,Output,Expss,我使用expss包生成mtcar数据的汇总表 library(expss) data(mtcars) mtcars %>% tab_cells(cyl) %>% tab_cols(total(), vs) %>% tab_rows(am) %>% tab_stat_cpct(total_row_position = "above", total_label = c("

我使用expss包生成mtcar数据的汇总表

library(expss)
data(mtcars)

mtcars %>% 
    tab_cells(cyl) %>% 
    tab_cols(total(), vs) %>% 
    tab_rows(am) %>% 
    tab_stat_cpct(total_row_position = "above",
                  total_label = c("number of cases", "row %"),
                  total_statistic = c("u_cases", "u_rpct")) %>% 
    tab_pivot()
我得到这样的输出:

现在我想将输出保存在html、pdf或jpeg文件中。 不幸的是,在循环之前或循环内操作save.image不起作用。一定有一个简单的解决办法?我还试图以某种方式从查看器中导出,但也失败了


此外,是否可以在一行中显示每个不同发动机的系数(即气缸)的案例数及其总体比例(例如n案例(xy%)?)

要将表格另存为html,您可以在序列末尾添加
htmlTable
函数,然后保存html代码:

library(expss)
data(mtcars)

mtcars %>% 
    tab_cells(cyl) %>% 
    tab_cols(total(), vs) %>% 
    tab_rows(am) %>% 
    tab_stat_cpct(total_row_position = "above",
                  total_label = c("number of cases", "row %"),
                  total_statistic = c("u_cases", "u_rpct")) %>% 
    tab_pivot() %>% 
    htmlTable() %>% 
    writeLines("my_table.html")
您可以使用以下代码在一行中生成案例和表格百分比:

library(expss)
data(mtcars)

mtcars %>% 
    tab_cells(cyl) %>% 
    tab_cols(total(), vs) %>% 
    tab_rows(am) %>% 
    tab_stat_cases(total_row_position = "none") %>% 
    tab_stat_tpct(total_row_position = "none") %>% 
    tab_pivot(stat_position = "inside_columns")

# |    |    |     |    | #Total |       | vs |       |    |       |
# |    |    |     |    |        |       |  0 |       |  1 |       |
# | -- | -- | --- | -- | ------ | ----- | -- | ----- | -- | ----- |
# | am |  0 | cyl |  4 |      3 | 15.79 |    |       |  3 | 15.79 |
# |    |    |     |  6 |      4 | 21.05 |    |       |  4 | 21.05 |
# |    |    |     |  8 |     12 | 63.16 | 12 | 63.16 |    |       |
# |    |  1 | cyl |  4 |      8 | 61.54 |  1 |  7.69 |  7 | 53.85 |
# |    |    |     |  6 |      3 | 23.08 |  3 | 23.08 |    |       |
# |    |    |     |  8 |      2 | 15.38 |  2 | 15.38 |    |       |
到目前为止,还没有将统计数据放在同一单元格的括号中的选项