[R] aggregate function with 'NA'
Peter Dalgaard
p.dalgaard at biostat.ku.dk
Sun Oct 1 14:14:30 CEST 2006
Frank <rggefrm at ucl.ac.uk> writes:
> aggregate(frame[,c(-1)],list(frame$Day,frame$Time),mean)
>
> My problem is now that I do not obtain a 'mean' for Day=M/Time=0 and
> Day=M/Time=1,
>
> because aggregate ignores all values for a grouping variable if NA
> occurs.
No. But mean() will give an NA result if any vaues are NA.
> I'm now hoping for some help so that the mean is still calculated in
> this group.
add na.rm=TRUE
--
O__ ---- Peter Dalgaard Øster Farimagsgade 5, Entr.B
c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-help
mailing list