View()ing gtables

The function View() seems to have problems when applied to objects of class "gtable". Example:

g <- ggplot2::ggplotGrob(
  ggplot2::ggplot(mtcars) + ggplot2::geom_point(aes(cyl, disp)))
View(g)

Error message: Error in names[[i]] : subscript out of bounds

Potentially, this is related to the fact that the class has overwritten the length-function:

length(g)  # gives 18
length(unclass(g)) # gives 12

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.