Hi All, I have a gTree (x1) produced by ggplot, with the following structure (output from grid.ls, edited): viewport[GRID.VP.15] frame[plot-surrounds] viewport[GRID.VP.16] cellGrob[GRID.cellGrob.137] rect[background] upViewport[1] viewport[GRID.VP.17] cellGrob[GRID.cellGrob.138] gTree[plot.gTree.96] viewport[layout] downViewport[panel_1_1] gTree[guide.gTree.81] [...] upViewport[2] downViewport[layout] [...] viewport[GRID.VP.18] cellGrob[GRID.cellGrob.139] viewport[GRID.VP.13] frame[legends] viewport[GRID.VP.14] cellGrob[GRID.cellGrob.132] viewport[GRID.VP.1] frame[legend.frame.100] viewport[GRID.VP.2] cellGrob[GRID.cellGrob.101] text[title.text.98] upViewport[1] viewport[GRID.VP.3] cellGrob[GRID.cellGrob.104] rect[key.rect.103] [...] viewport[GRID.VP.19] cellGrob[GRID.cellGrob.140] text[ylabel.text.136] upViewport[1] viewport[GRID.VP.20] cellGrob[GRID.cellGrob.141] text[xlabel.text.134] upViewport[1] viewport[GRID.VP.21] cellGrob[GRID.cellGrob.142] text[title] upViewport[1] upViewport[1] However, when I do unused argument(s) (recursive = TRUE)> x2 <- getGrob(x1, gPath=gPath("plot-surrounds", "GRID.cellGrob\\.[1-9]*", > "legends"), grep=TRUE, global=TRUE)I get NULL> x2NULL But if I do> x4 <- grid.ls(x1, grobs=TRUE, fullNames=FALSE, recursive=TRUE, > print=FALSE, flatten=TRUE)and then I do> grep(gPath("plot-surrounds", "GRID.cellGrob\\.[1-9]*", "legends"), x3)I get the right result [1] 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 Can anyone tell me why this is happening, and how should I do to get this grob? Thanks, Pedro -- View this message in context: http://www.nabble.com/%22grep%22-argument-not-working-in-%22getGrob%22--tp19760956p19760956.html Sent from the R help mailing list archive at Nabble.com.