On 3/15/2012 4:11 PM, tibaker wrote:
Hi

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 (printed).

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()
suppressMessages(print(p))

If you are getting display by implicit printing of the plot, then this won't work.

--
Brian S. Diggs, PhD
Senior Research Associate, Department of Surgery
Oregon Health & Science University

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to