[R] get level combinations from "by" list

From: bogdan romocea <br44114_at_gmail.com>
Date: Thu 09 Jun 2005 - 00:56:19 EST


Dear useRs,

Given this code I end up with a list of class "by":

a <- sample(1:5,200,replace=TRUE)
b <- sample(c("v1","v2","v3"),200,replace=TRUE)
c <- sample(c(11,22,33),200,replace=TRUE)
data <- runif(200)
grouped <- by(data,list(a,b,c),function(x) {c(min=min(x),max=max(x),
	median=round(median(x),digits=2),mean=round(mean(x),digits=2))})
dfr <- do.call("rbind",grouped) #the levels are missing #----------
grouped
typeof(grouped)
class(grouped)
dimnames(grouped)  

How do I get at the levels of the 'group by' variables for each subset? For example, from this part of the "by" list I want 4, v2 and 33:
: 4
: v2
: 33

      min max median mean
0.3897450 0.9215315 0.7300000 0.6700000


Thank you,
b.



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 Jun 09 01:01:43 2005

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