Skip to Main Content
HBS Home
  • About
  • Academic Programs
  • Alumni
  • Faculty & Research
  • Baker Library
  • Giving
  • Harvard Business Review
  • Initiatives
  • News
  • Recruit
  • Map / Directions
Research Computing Services
  • Online Requests
  • FAQ
  • Blog
  • Contact Us
  • About Us
  • Faculty Projects
  • Training
  • Compute Cluster & Data Storage
  • Data Practices
  • Help
  • …→
  • Harvard Business School→
  • Research Computing Services→
  • Help
    • Help
    • Online Requests
    • Technical How-To’s & Notes
    • Frequently Asked Questions
    →
  • Technical How-To’s & Notes→

Technical How-To’s & Notes

Technical How-To’s & Notes

Saving Plots & Images in R

Saving Plots & Images in R

Process

If you generate a plot in R and want to save it, then you would typically use the following protocol:

png(file = FILEPATH)

plot

dev.off()

Unfortunately, using this approach on the Grid does not work for the most common image types (PNG, JPG, and TIFF). However, you may store your plots as BMP or bitmap. To do so, follow this syntax:

bitmap(file = FILEPATH)

plot

dev.off()

To view your plots, you may either transfer the files to your local machine, or map/mount the Grid folder to your local PC/Mac, then view the files as you would any other.

For further information on either option, please visit https://hbs-rcs.github.io/hbsgrid-docs/syncfiles/

Example Working Code

The following code will generate a histogram with light green bars. The resulting bitmap will be saved as “testplot.bmp” to your home directory (“~/” denotes home directory)

x=rnorm(50, mean=0, sd=1)

bitmap(file=”~/testplot.bmp”)

hist(x, breaks=10, col=’lightgreen’)

dev.off()

ǁ
Campus Map
Research Computing Services (RCS) 
Harvard Business School
Baker Library, B90, 25 Harvard Way
Boston, MA 02163
Phone: 617.495.6100
Email: research@hbs.edu
→Map & Directions
→More Contact Information
→Terms Of Service
  • Make a Gift
  • Site Map
  • Jobs
  • Harvard University
  • Trademarks
  • Policies
  • Accessibility
  • Digital Accessibility
Copyright © President & Fellows of Harvard College