Re: [R] regression line on boxplots

From: Bernd Weiss <>
Date: Fri, 01 Apr 2011 11:45:03 -0400

Am 01.04.2011 11:24, schrieb Yan Jiao:
> Dear R users,
> I'm trying to add a regression line on my boxplots (something
> like:boxplot(c(1:3),c(4:6),c(5:8))) But I can't see it. Please help
> !!! It's not a April fool's joke!!!

Your sample data does not make any sense (at least to me). I would do it as follows:

df <- data.frame(y = rnorm(100), x = factor(rep(1:4))) boxplot(y ~ x, data = df)
regline <- lm(y ~ as.numeric(x), data = df) abline(regline)

HTH, Bernd mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Fri 01 Apr 2011 - 15:47:35 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 01 Apr 2011 - 15:50:26 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive