The png() function opens a PNG graphics device, plot() draws the scatter of age versus salary, and dev.off() closes the device and finalizes the file. Forgetting dev.off() leaves the file empty or truncated. The resulting rplot.png appears in the working directory. Use hist() instead of plot() for a single-column distribution.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.