# This R script is an example on how to save / create plots directly as a pdf, tiff or jpg file # The plots are stored in the default folder of JGR # Create a subfolder called 'MyRPlots' to store the created plots: dir.create('MyRPlots') # Use the first Anscombe set as an example: x1<-c(10,8,13,9,11,14,6,4,12,7,5) y1<-c(8.04,6.95,7.58,8.81,8.33,9.96,7.24,4.26,10.84,4.82,5.68) # Put in a data frame: ans<-data.frame(x1,y1) # plot the first Anscombe set in the plot window: library(ggplot2) # use the ggplot2 library ans1<-ggplot() + geom_point(aes(x1,y1),data=ans) +theme_bw() # create the plot in 'ans1' ans1 # plot in the window # to create a pdf in the MyRPlots folder: pdf('MyRPlots/anscombe1.pdf') ans1 dev.off() # to create a tiff in the MyRPlots folder: tiff('MyRPlots/anscombe1.tif') ans1 dev.off() # to create a jpg in the MyRPlots folder: jpeg('MyRPlots/anscombe1.jpg', quality=100,width=960,height=960,res=200) ans1 dev.off()