gpt4 book ai didi

r - 如何用tableGrob显示表格的标题?

转载 作者:行者123 更新时间:2023-12-03 03:53:01 24 4
gpt4 key购买 nike

考虑这个例子

library(gridExtra)
library(grid)

d1 <- head(iris[,1:3]) %>% as_tibble()
d2 <- head(iris[,2:5]) %>% as_tibble()

grid.arrange(tableGrob(d1),
tableGrob(d2))

这给出了 enter image description here

这真的很好,但我缺少数据框的标题!如何将它们自动添加到图片中?

谢谢!

最佳答案

您可以使用ggplot

library(ggplot2)

dd1 <- ggplot() + annotation_custom(tableGrob(d1)) + labs(title = 'd1')
dd2 <- ggplot() + annotation_custom(tableGrob(d2)) + labs(title = 'd2')
grid.arrange(dd1, dd2, nrow = 2)

enter image description here

关于r - 如何用tableGrob显示表格的标题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54217329/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com