[R] plot vs print ??
Greg.Snow at imail.org
Thu Nov 18 00:40:07 CET 2010
Well, assuming this refers to the histogram function in the lattice package, looking at the code for print.trellis shows that the default behavior is to call plot.trellis with the same arguments. So unless you change the default behavior, there really is no difference between printing and plotting (except maybe one more step in the call stack).
Using print can allow you to do something else if you set the print.function option in lattice to something else. The idea of "printing" graphs to plot them comes because the R interpreter will print (call the print method) on objects that are returned from functions at the top level and not saved into a variable (and possibly other cases), having a print method that plots means that calls to histogram and others without saving or doing other things will cause the object to be plotted, which is generally what the user wants.
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
greg.snow at imail.org
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of skan
> Sent: Tuesday, November 16, 2010 10:10 AM
> To: r-help at r-project.org
> Subject: [R] plot vs print ??
> What's the differente betwen using "plot" and using "print" in order
> plot a graph?
> For example in order to plot the result of a histogram.
> View this message in context: http://r.789695.n4.nabble.com/plot-vs-
> Sent from the R help mailing list archive at Nabble.com.
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help