Skip to content
Back to formatted view

Raw Message

Message-ID: <4D95F2FF.5000606@uni-koeln.de>
Date: 2011-04-01T15:45:03Z
From: Bernd Weiss
Subject: regression line on boxplots
In-Reply-To: <7785EFE1CC2D9F4A96F6A415BC1C2BD0168DD480@PC6-46.pogb.cancer.ucl.ac.uk>

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:

set.seed(8)
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