On Mon, 30 May 2011 16:47:45 -0500, "Mendolia, Franco" <fmendo...@mcw.edu> wrote:
> Hello, I would like to create a group variable that is based on the > values of three variables: > For example, >> dat <- data.frame(A=c(1,1,1,1,1,2,2,2,2,2), > B=c(1,1,1,5,5,5,9,9,9,9), > C=c(1,1,1,1,1,2,2,7,7,7)) >> dat > A B C 1 1 1 1 2 1 1 1 3 1 1 1 4 1 5 1 5 1 5 1 6 2 5 2 7 2 9 2 8 2 9 > 7 9 2 9 7 10 2 9 7 [...] One option: dat <- within(dat, {grp <- factor(paste(A, B, C))}) -- Seb ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.