From pdalgd at gmail.com  Sat Apr 30 01:11:16 2016
From: pdalgd at gmail.com (peter dalgaard)
Date: Sat, 30 Apr 2016 01:11:16 +0200
Subject: [Rd] boxplot with formula involving two-factor levels
In-Reply-To: <A0910CA43C834C6FB03CE582BBA660D3@science.oregonstate.edu>
References: <A0910CA43C834C6FB03CE582BBA660D3@science.oregonstate.edu>
Message-ID: <1A4F3B70-0939-4A71-885C-9AFF2B92DBB7@gmail.com>


> On 29 Apr 2016, at 23:54 , diy at stat.oregonstate.edu wrote:
> 
> Hi,
> 
> I noticed two seemingly equivalent call to boxplot will give different plots (in the way how the combined factor levels are arranged on the x-axis): 
> 
> x = factor(rep(c("a", "b", "c"), each=2));
> y = rep(factor(c("one", "two")), each=3);
> r = 3;
> n = r * 6;
> x = rep(x, 3);
> y = rep(y, 3);
> z = rnorm(n);
> 
> par(mfrow=c(2,1));
> 
> ## The following two seeming equivalent calls to boxplot give different results
> boxplot(z~x:y);
> 
> f = x:y;
> boxplot(z~f);
> 
> This is puzzling to me. Is this normal? 

Normal, but a little odd. The root cause is the difference between x:y and interaction(x,y), documented on the help page for the latter.

-pd


> Thanks!
> 
> Best,
> Yanming
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com



[Rd] boxplot with formula involving two-factor levels
peter dalgaard