将数据框紧接在pdf中放置

时间:2013-07-18 18:01:38

标签: r

我有一个matrices data.list列表,我试图在一个pdf上一个接一个地显示它们,并带有标题。列表的元素由名为row.vector的列表元素索引。

这是我的代码:

pdf("data.pdf", height = 11, width = 8.5)
for (i in 1:length(row.vector)) {
    grid.arrange(tableGrob(data.list[[row.vector[[i]]]], gp=gpar(fontsize=6)), main = row.vector[[i]])
}
dev.off()

这有两个问题。   - 所有矩阵都显示在不同的页面上,尽管它们都不足以保证页面。我希望它们一个接一个地显示出来。   - 标题位于页面顶部,我希望它们位于桌面上方。 我还想把图表放在表格之间(没有水平相邻的表格或图表)。

以下是测试列表:

row.vector <- list("first", "second", "third")
a <- matrix(nrow = 4, ncol = 3)
a[1,] <- c(3,4,5)
a[2,] <- c(6,7,8)
a[3,] <- c(1,1,1)
a[4,] <- c(1,1,1)
b<- matrix(nrow = 2, ncol = 3)
b[1,] <- c("a","x","y")
b[2,] <- c("d","d","d")
c <- matrix(nrow = 10, ncol = 2)
c[,1] <- 1:10
c[,2] <- 11:20
data.list <- list("first" = a,"second"=b,"third"=c)

0 个答案:

没有答案