使用expss包的行标签 [英] Row label using expss package
本文介绍了使用expss包的行标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以在每行上重复标签,以使以下代码的输出看起来类似:
Is it possible to repeat labels on each row such that the output of below code should look alike:
代替:
其中所需的输出应在每行而不是仅第一行包含标签.
wherein the desired output should contain the labels on each row instead of first row only.
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()
推荐答案
如果将as.datatable_widget
函数用于输出,则有一个特殊的参数repeat_row_labels
.将其设置为TRUE
可获得所需的结果.如果您使用的是split_columns
,则存在另一个名称不一致的其他参数,称为remove_repeated
.将其设置为FALSE
以重复行标签.
If you are using as.datatable_widget
function for output then there is a special argument repeat_row_labels
. Set it to TRUE
to get desired result. If you are using split_columns
there is an other argument which is inconsistently named as remove_repeated
. Set it to FALSE
to repeat row labels.
这篇关于使用expss包的行标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文