[R] how to eliminate ggplot warning frrom "knitted" document

Daniel Nordlund djnordlund at frontier.com
Tue Nov 17 00:04:02 CET 2015


I have the following data.

sumry <- structure(list(group = structure(c(1L, 1L, 1L, 2L, 2L, 2L), 
.Label = c("A",
"B"), class = "factor"), level = c(0.5, 1, 2, 0.5, 1, 2), n = c(10,
10, 10, 10, 10, 10), mean = c(13.23, 22.7, 26.06, 7.98, 16.77,
26.14), sd = c(4.45, 3.91, 2.65,
2.74, 2.51, 4.79), se = c(1.41,
1.23, 0.83, 0.86, 0.79,
1.51), lcl = c(10.03, 19.90,
24.16, 6.01, 14.972, 22.70
), ucl = c(16.42, 25.49, 27.95,
9.94, 18.56, 29.57)), .Names = c("group",
"level", "n", "mean", "sd", "se", "lcl", "ucl"), row.names = c(NA,
6L), class = "data.frame")

I want to plot the means with 95% confidence intervals for the means.  I 
can use the following ggplot code to get the plot.

ggplot(sumry, aes(x=level, y=mean, group=group, color=group)) +
   geom_line() +
   geom_point()+
   geom_errorbar(aes(ymin=lcl, ymax=ucl), width=.2)

I initially tried using position_dodge() to keep the error bars from 
plotting completely on top of each other.  However, I kept getting the 
following warning:

ymax not defined: adjusting position using y instead

I am using knitr to create a pdf document and the warning is cluttering 
up my pdf document. Is there anyway to alter the plot statement to avoid 
the warning?  If not, is there a way to get knitr not to print out the 
warning to the markdown document so that it doesn't end up in the pdf 
document?


Thanks,

Dan

-- 
Daniel Nordlund
Bothell, WA  USA



More information about the R-help mailing list