[R] show and produce PDF file with pdf() and dev.off( ) in function

chuck.01 CharlieTheBrown77 at gmail.com
Sat Mar 24 03:03:52 CET 2012


1) thats not a function (i'm sure just a mistake)
2) Just add another plot line 

myplot <- function(x){ 
  plot(x) 
  pdf("xplot.pdf") 
  plot(x) 
  dev.off() 
} 

myplot(1:20)





casperyc wrote
> 
> Hi all,
> 
> I know how to use pdf() and dev.off() to produce and save a graph.
> 
> However, when I put them in a function say 
> 
> myplot(x=1:20){
>   pdf("xplot.pdf")
>   plot(x)
>   dev.off()
> }
> 
> the function work. But is there a way show the graph in R as well as
> saving it to the workspace?
> 
> Thanks.
> 
> casper
> 


--
View this message in context: http://r.789695.n4.nabble.com/show-and-produce-PDF-file-with-pdf-and-dev-off-in-function-tp4500213p4500595.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list