我试图从 gt() 表中删除字符串,但没有成功。在我的表中,我想要多个列名/标题,涵盖名为“Day 0”、“Day 4”、“Day 10”、“Day 17”的两列以及名为“mean”和“se”的子列。在查看数据时可能更容易理解。
我现在想要的是从子列中删除“第 0 天”(或例如“第 4 天”)。有什么建议么?
我的代码:
library(gt)
gt(mean_se)%>%
tab_spanner(label = "Day 0", columns = matches("0")) %>%
tab_spanner(label = "Day 4", columns = matches("4")) %>%
tab_spanner(label = "Day 10", columns = matches("10")) %>%
tab_spanner(label = "Day 17", columns = matches("17")) %>%
tab_header(
title = md("Biogenic volatile organic compound emissions"))
# str_remove(mean_se, "day 0")
# rename("mean"=="mean day 0")
这是数据:
mean_se <- structure(list(mass = c("i.x33.031", "i.x35.034", "i.x36.017",
"i.x39.959", "i.x40.023"), `mean day 0` = c("241.82", "0.36",
"1.78", "0.2", "1.82"), `se day 0` = c("241.82", "0.36", "1.78",
"0.2", "1.82"), `mean day 4` = c("32.94", "0.14", "0", "0", "1.74"
), `se day 4` = c("32.94", "0.14", "0", "0", "1.74"), `mean day 10` = c("266.28",
"0.6", "0", "0", "1.58"), `se day 10` = c("266.28", "0.6", "0",
"0", "1.58"), `mean day 17` = c("451.4", "0.48", "0", "0", "2.94"
), `se day 17` = c("451.4", "0.48", "0", "0", "2.94")), row.names = c(NA,
-5L), class = "data.frame")