Re: [R] Single factor from interaction.

From: Chuck Cleland <ccleland_at_optonline.net>
Date: Thu 26 May 2005 - 22:41:26 EST

Are you looking for interaction() ?

a <- gl(2, 4, 8)
b <- gl(2, 2, 8, label = c("ctrl", "treat"))
s <- gl(2, 1, 8, label = c("M", "F"))

interaction(a, b)
[1] 1.ctrl 1.ctrl 1.treat 1.treat 2.ctrl 2.ctrl 2.treat 2.treat Levels: 1.ctrl 2.ctrl 1.treat 2.treat

interaction(a, b, s, sep = ":")
[1] 1:ctrl:M 1:ctrl:F 1:treat:M 1:treat:F 2:ctrl:M 2:ctrl:F 2:treat:M 2:treat:F

Levels: 1:ctrl:M 2:ctrl:M 1:treat:M 2:treat:M 1:ctrl:F 2:ctrl:F 1:treat:F 2:treat:F

Rolf Turner wrote:
> I have a vague recollection of seeing reference, fairly recently, to
> a function that forms a single factor which ``codes'' the interaction
> between two (or more?) factors. Do I recollect correctly? It would
> be easy enough to roll one's own, but if there is an existing
> function it probably does a much cleverer job than I would do.

-- 
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 452-1424 (M, W, F)
fax: (917) 438-0894

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Thu May 26 22:47:04 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:32:07 EST