0

是否可以在每一行上重复标签,以使以下代码的输出看起来相似:在此处输入图像描述

代替: 在此处输入图像描述

其中所需的输出应包含每一行的标签,而不仅仅是第一行。

library("expss")
data(mtcars)
mtcars = apply_labels(mtcars,
                      mpg = "Miles/(US) gallon",
                      cyl = "Number of cylinders",
                      disp = "Displacement (cu.in.)",
                      hp = "Gross horsepower",
                      drat = "Rear axle ratio",
                      wt = "Weight (lb/1000)",
                      qsec = "1/4 mile time",
                      vs = "Engine",
                      vs = c("V-engine" = 0,
                             "Straight engine" = 1),
                      am = "Transmission",
                      am = c("Automatic" = 0,
                             "Manual"=1),
                      gear = "Number of forward gears",
                      carb = "Number of carburetors"
)
 mtcars %>% 
     tab_cells(cyl, gear) %>% 
     tab_prepend_all %>% 
     tab_cols(total(), vs) %>% 
     tab_stat_cpct() %>% 
     tab_pivot()
4

1 回答 1

0

如果您使用as.datatable_widget函数进行输出,则有一个特殊参数repeat_row_labels。将其设置TRUE为获得所需的结果。如果您使用split_columns的是另一个参数,它的命名不一致remove_repeated。将其设置FALSE为重复行标签。

于 2018-06-21T17:47:36.890 回答