[R] na.action in model.tables and TukeyHSD

CG Pettersson cg.pettersson at evp.slu.se
Fri Feb 28 11:51:03 CET 2003


In 27/2, I got the following answer from Prof. Ripley: (The question is at the bottom)

>This ia already fixed in R-devel.  The answer is the same: don't use
>na.omit implicitly: use it explicitly. 

I feel rather stupid for the moment, as I don´t understand an answer that looks very simple.
What´s the code to do the trick using na.omit explicitly? (Preferably starting with my code in the question)
I can´t get it to work, so my tries are not worth printing here...

Thanks
/CG

On Wed, 26 Feb 2003, CG Pettersson wrote: > Hello everybody!
>
> I use R 1.6.2 in Windows, and have a problem controlling the na.action.
>
> In a dataset with twelve trials, one of the trials lack any readings of the variable "STS.SH" (standing power at harvest)
>
> Fitting an aov() object with the call:
> led1t7sts.aov <- aov(STS.SH ~ Trial/Block + Treatment + Treatment:Trial, data = led1t7, na.action=na.exclude) 
> seems to work as it produces an object with 10 df for the factor "Trial".
>
> But when I use model.tables or TukeyHSD on the object I get this:
> > model.tables(led1t7sts.aov, "means")
> Error in replications(paste("~", paste(names(tables), collapse = "+")),  :
>         na.action must be a function
>
> I have tried to use "na.action=na.exclude" inside the model.tables call as well, without any bettering.
>
> I can naturally cope with the problem by taking the whole trial away from the dataset, but it doesn´t feel very sophisticated...;-)
> (Prof. Ripley answered a similar question from me two weeks ago. The answer was good but didn´t work as the reason of the error was the same as this time: a 
whole
> trial with only na:s in it).
>
> Thanks
> /CG
> CG Pettersson
> cg.pettersson at evp.slu.se
CG Pettersson
cg.pettersson at evp.slu.se




More information about the R-help mailing list