Export the plot to a pdf or png - R

0 votes

Hi, I want to export the plots into images and store them for presentation purpose. I used below code -

> png("annual sales.png")
> ggplot(economics, aes(date, unemploy)) + geom_ribbon(aes(ymin = unemploy,ymax = unemploy +900), fill = "blue")

But it is not showing any images. What to do?

Jul 15 in Data Analytics by Nithin
60 views

1 answer to this question.

0 votes

You need to close the device to see the image or file because its running in R.

Write below code - 

dev.off() 

After device completes its work to store the output in an external file, you need to close the connection of the device.

Ex:

png(filename="your/file/location/name.png")
plot(variable,[options])
dev.off()

Close the file and reopen the file to see the output file.

answered Jul 15 by anonymous

Related Questions In Data Analytics

0 votes
1 answer
0 votes
1 answer

How to edit the labels and limit if a plot using ggplot? - R

Add a limit to axis ticks using ...READ MORE

answered Nov 3 in Data Analytics by anonymous
• 32,260 points
22 views
0 votes
1 answer

How to convert a text mining termDocumentMatrix into excel or csv in R?

By assuming that all the values are ...READ MORE

answered Apr 5, 2018 in Data Analytics by DeepCoder786
• 1,720 points
173 views
0 votes
1 answer

Save a plot as image on the disk using R

Consider for both the situations: 1. Image will ...READ MORE

answered Apr 13, 2018 in Data Analytics by darklord
• 6,190 points
156 views
0 votes
0 answers

How to add custom labels to charts in R?

How to add custom labels to charts ...READ MORE

Jul 3 in Data Analytics by Prerana
18 views
0 votes
0 answers

How to add color legend for box plots in R?

How to add color legend for box ...READ MORE

Jul 3 in Data Analytics by keerthi
25 views
0 votes
0 answers
0 votes
0 answers

R plots to show categorical fields in graphs

Which R plots are best to show ...READ MORE

Jul 9 in Data Analytics by nikita
30 views
0 votes
1 answer

How to check if a file already exists or not in R?

Check out file.exists() function!! The function file.exists() returns a ...READ MORE

answered Oct 29 in Data Analytics by Cherukuri
• 32,260 points
37 views
0 votes
2 answers

How to count the number of elements with the values in a vector?

Use dplyr function group_by(). > n = as.data.frame(num) > ...READ MORE

answered Aug 21 in Data Analytics by anonymous
• 32,260 points
134 views