Search code examples
rplotfigurerscript

How to display figures using RScript?


I know RScript is non-interactive, but I would like to display figures without running into the R interactive console first (the same way as in python and java).

In other words, I am hoping to be able to run a single build command from command prompt or terminal that runs an R script and displays its figures.

Thanks.


Solution

  • If you are familiar with shiny you can build simple shinyApp to display file.png file in browser:

    Rscript -e 'png("file.png"); plot(1:10); dev.off(); runApp("display_png_app")'
    

    Good comment by @Ista: you don't need to use shiny, you can simply use browseURL("file.png") command instead runApp.