Try this for drawing table on a pdf file that span multiple pages using gridExtra package:
Adjust pdf device aspect ratio
pdf(file = myfile.pdf, height = 12, width = 26)
Split the large data frame into chunks and call grid.newpage before drawing a table.
require(gridExtra)
pdf(file = myfile.pdf, height = 12, width = 26)
grid.newpage()
grid.table(sga_hits[1:38, ], show.rownames = FALSE)
grid.newpage()
grid.table(sga_hits[39:75, ], show.rownames = FALSE)
dev.off()
Automate the above as follows:
require(gridExtra)
pdf(file = myfile.pdf, height = 12, width = 26)
total_rows_per_page = 38
start_row = 1
if(total_rows_per_page > nrow(sga_hits)){
end_row = nrow(sga_hits)
}else {
end_row = total_rows_per_page
}
for(i in 1:ceiling(nrow(sga_hits)/total_rows_per_page)){
grid.newpage()
grid.table(sga_hits[start_row:end_row, ], show.rownames = FALSE)
start_row = end_row + 1
if((total_rows_per_page + end_row) < nrow(sga_hits)){
end_row = total_rows_per_page + end_row
}else {
end_row = nrow(sga_hits)
}
}
dev.off()
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…