Use the rasterGrob
function:
result <- rasterGrob(redGradient)
The two functions share a documentation page, but looking at the source, you can see that grid.raster
creates the grob and then draws it, returning the value of grid.draw
(NULL
), whereas rasterGrob
simply returns the grob.