如何从表格中删除单元格标签? [英] How do you remove the cell label from your table?

查看:185
本文介绍了如何从表格中删除单元格标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试利用expss来自动执行目前通过R在Excel中完成的某些报告.我通常需要总结一些相对于某些字段(列)的某些分组(行)中的许多值.我发现很难摆脱单元格描述.

I'm trying to leverage expss to automate some reporting currently done in Excel via R. I'm generally needing to summarise a lot of values across some grouping (rows) relative to some fields (columns). I'm finding it difficult to get rid of the cell description.

这是一个例子:

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()

您会看到高度"作为标签打印出来,请问如何去除它?

You will see that "height" is printed as a label, how do I get rid of it please?

谢谢!

推荐答案

"|"分配为标签会同时禁止标签和变量名:

"|" assigned as label suppress both label and variable name:

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()

这篇关于如何从表格中删除单元格标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆