我有在格式化使用一些表格一些麻烦expss的一个R Markdown。输出是一个pdf文件。knitr选项是:
knitr::opts_chunk$set(echo = FALSE, message = FALSE, warning = FALSE)
Run Code Online (Sandbox Code Playgroud)
跟随小插图expss(可在此处获得https://cran.r-project.org/web/packages/expss/vignettes/tables-with-labels.html),我编写了以下代码:
sl_expss_long %>% # the tibble
calc_cro_cpct(
cell_vars = list(br, cl, cm, fgm, vd), # rows
col_vars = list(total(), area) # columns
) %>%
set_caption("Table 1")
Run Code Online (Sandbox Code Playgroud)
此代码在 中运行良好R Studio,并生成此表:
Table 1
| | | #Total | Area | |
| | | | Rural | Urban |
| ------------------------------------ | ------------ | ------- | ------ | ------ …Run Code Online (Sandbox Code Playgroud)