Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Preview a saved PNG in an R device window

Tags:

Is there a way print an existing PNG file to the device window, for example, let's say that you have saved a plot as PNG but you would like to preview it (for sanity) before placing it in a presentation or a document.

Ideally, I'd like to be able to 'push' the image into the RStudio 'plots' window.

like image 268
Brandon Bertelsen Avatar asked Feb 16 '12 21:02

Brandon Bertelsen


People also ask

How do I view a PNG file?

How to open a PNG file. Nearly all built-in image editing programs can open PNG files. Whether you use a Mac or Windows computer, simply search for the file name and double-click on it. You can then choose the program you want to use from the list of options your computer gives you.

How do I open a PNG file in Windows Photo Viewer?

You can right click on PNG file, select Open with > Photos. Note that Photos app came pre-installed with Windows 10. If you still can't find Photos app on your system, install it from Microsoft Store. Hope this helps!


1 Answers

You can import it and display it in R,

library(png) img <- readPNG(system.file("img", "Rlogo.png", package="png")) grid::grid.raster(img) 
like image 200
baptiste Avatar answered Oct 23 '22 17:10

baptiste