質問

I'm plotting database performance data, mostly with ggplot2. There are 8 pages of relatively complex plots and 2 pages of tableGrobs. I just instrumented my code to figure out where I'm spending time and out of 25 seconds total, 13 of those seconds are on the last 2 pages which are the tableGrobs. That 25 seconds includes loading the data, doing serious parsing with stringR, etc. Here's the example output: https://www.dropbox.com/s/3s6bi70py5pgpdm/PSPROD-259-341-1-plot.pdf , though the last page for those timings has 75 rows and 17 columns.

So, is this what others are seeing? Is there an alternative to tableGrob that might be faster?

The code I'm using to produce the SQL table is:

sqlSummaryText1 <- tableGrob(head(subset(main$DF_SQL_SUMMARY, 
                                         select=-c(PX_EXEC,LOG_READS)),75),
                             show.rownames = FALSE, 
                             gpar.coretext = gpar(fontsize=5),
                             gpar.coltext = gpar(fontsize=5),
                             padding.v = unit(1, "mm"),
                             padding.h = unit(1, "mm"),
                             show.colnames = TRUE,
                             col.just = "left", 
                             gpar.corefill = gpar(fill=NA,col=NA),
                             h.even.alpha = 0 )
grid.arrange(sqlSummaryText1,ncol = 1, widths=c(1))
役に立ちましたか?

解決

It is difficult to imagine something slower than grid.table, almost any alternative would be much faster. You could use textplot or addtable2plot in base graphics, or the various options to produce tables in pdf documents processed by Sweave/knitr etc.

The main reason grid.table is slow is because each cell contains an individual textGrob; it would be much faster, but less versatile and more cumbersome to implement, to have a single textGrob for all labels (see example 2 of this document). A basic implementation is shown here.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top