我正在尝试利用expss来自动化通过R在Excel中当前完成的某些报告。我通常需要总结一些相对于某些字段(列)的某些分组(行)中的许多值。我发现很难摆脱单元格描述。
这是一个例子:
animals <- data.table(
animal = c(1, 1, 2, 2, 3, 3, 4, 4),
standing = c(1, 2, 1, 2, 1, 2, 1 ,2),
height = c(50, 70, 75, 105, 25, 55, 10, 20)
)
animals <- expss::apply_labels(
animals,
animal = "animal",
animal = c("cat" = 1, "dog" = 2, "turtle" = 3, "rat" = 4),
standing = "standing",
standing = c("no" = 1, "yes" = 2),
height = "height"
)
expss::expss_output_viewer()
animals %>%
expss::tab_cells(height) %>%
expss::tab_cols(animal) %>%
expss::tab_rows(standing) %>%
expss::tab_stat_sum(label = "") %>%
expss::tab_pivot()
您会看到“高度”作为标签打印,请问如何去除它?
谢谢!
“ |” 分配为标签同时禁止标签和变量名:
library(expss)
animals <- data.table(
animal = c(1, 1, 2, 2, 3, 3, 4, 4),
standing = c(1, 2, 1, 2, 1, 2, 1 ,2),
height = c(50, 70, 75, 105, 25, 55, 10, 20)
)
animals <- expss::apply_labels(
animals,
animal = "animal",
animal = c("cat" = 1, "dog" = 2, "turtle" = 3, "rat" = 4),
standing = "standing",
standing = c("no" = 1, "yes" = 2),
height = "|" # to suppress label
)
expss::expss_output_viewer()
animals %>%
expss::tab_cells(height) %>%
expss::tab_cols(animal) %>%
expss::tab_rows(standing) %>%
expss::tab_stat_sum(label = "") %>%
expss::tab_pivot()
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句