[R] ggplot2: goem_smooth and suppress messages
diggsb at ohsu.edu
Fri Mar 16 20:32:58 CET 2012
On 3/15/2012 4:11 PM, tibaker wrote:
> When I run my script using ggplot and geom_smooth I get messages that I
> would like to suppress:
> p<- ggplot(dataSubset)
> p<- p + aes(x = as.Date(factor(key),format="%Y%m%d")) + geom_line()
> p<- p + geom_smooth(span=0.2,se=FALSE,size=0.7)
> The messages look like this:
> geom_smooth: method="auto" and size of largest group is<1000, so using
> loess. Use 'method = x' to change the smoothing method.
> There were 15 warnings (use warnings() to see them)
The warning is printed not when p is assigned, but when it is plotted
> I have tried
> p<- p + suppressMessages(geom_smooth(span=0.2,se=FALSE,size=0.7))
> but this does not work. I would like to keep using method="auto" but without
> any messages.
> Any ideas on how to suppress the messages when using geom_smooth?
> Thank you!
Use suppressWarnings when printing.
p <- ggplot(mtcars, aes(wt, mpg)) + geom_smooth()
If you are getting display by implicit printing of the plot, then this
Brian S. Diggs, PhD
Senior Research Associate, Department of Surgery
Oregon Health & Science University
More information about the R-help