Search code examples
rroxygen2

(R)How to add importFrom for grid.newpage()?


My goal is to convert R code to package. And the code contain grid.newpage() like this as below. How to add importFrom comment? Because when I tried "#' importFrom grid newpage", package doesn't show graph.(Maybe the newpage() is not actually from grid?)

showTest <-function() {
  library(grid)
  grid.newpage()
    pushViewport(viewport(layout = grid.layout(1, 1)))
     print(plot(sin, -pi, 2*pi), vp=viewport(layout.pos.row=1 ,layout.pos.col=1))      
}

Solution

  • The package is called grid, and the function is called grid.newpage so the form you need is

    #' importFrom grid grid.newpage