Erik Iverson wrote:
## BEGIN R CODE
## guarantees there is at least one level with exactly three elements,
## which your problem seems to require
t1 <- data.frame(a = rnorm(10), b = c("D", "D", "D", sample(LETTERS[1:3], 7, replace = TRUE)))

## find which names have exactly three elements
t2 <- subset(t1, b %in% names(which(table(t1$b) == 3)))

## note that the elements of the returned value depend on what was
## originally in your data set's 'b' column
tapply(t2$a, t2$b, mean)

## END R CODE


Hi,

Thank you all for the kind help. Now I've learned much and solved my problem with your helpful information :)

Cheers,
Leon

______________________________________________
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.

Reply via email to