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, 2019 in Data Analytics by Nithin
2,679 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, 2019 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, 2019 in Data Analytics by anonymous
• 33,030 points
714 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
1,920 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 14, 2018 in Data Analytics by Sahiti
• 6,370 points
2,146 views
0 votes
0 answers

How to add custom labels to charts in R?

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

Jul 4, 2019 in Data Analytics by Prerana
841 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 4, 2019 in Data Analytics by keerthi
1,588 views
+1 vote
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, 2019 in Data Analytics by nikita
562 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, 2019 in Data Analytics by Cherukuri
• 33,030 points
68,127 views
+1 vote
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, 2019 in Data Analytics by anonymous
• 33,030 points
5,019 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP