Le Fri, May 09, 2008 at 11:23:37PM -0400, Dipankar Basu a écrit :
> > ex <- data.frame(id=id,year=year,x=x)
> > ex1 <- subset(ex[which(ex$id=="A"|ex$id=="B"),])
> > tapply(ex1$x, ex1$id, mean)
>   A    B    C
> 22.5 32.5   NA

Dear Dipankar,

The reason for this behaviour is that the class of ex$id is "factor".
You can avoid this by using the I command, like in:

ex <- data.frame(id=I(id),year=year,x=x)

Have a nice day,

-- 
Charles Plessy
http://charles.plessy.org
Wakō, Saitama, Japan

______________________________________________
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