[R] NA points in loess function

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri Jun 27 18:05:13 CEST 2003


On Fri, 27 Jun 2003, Yao, Minghua wrote:

> Gurus,
> 
> I used
> 	predict(loess(Y~X));
> 
> where Y and X are of the same length. But there are same NA's in both Y and
> X. Those NA's are in the same locations in Y and X. The following is the
> error messageI got:
> 
> Error in "[<-"(*tmp*, , i, value = predict(loess(Y~X))) : 
>         number of items to replace is not a multiple of replacement length
> 
> If I replaced the NA's with a number, the function worked. What I want to do
> is to ignores those NA's. help(loess) doesn't say how to give value to
> na.action. It just says the default is to stop. Please help. Thank you in
> advance.

You use na.action=na.exclude (to whatever), that is you give the argument 
a value just like any other argument.

?na.exclude may help you.

However, your error message is not coming from predict or loess but from 
your usage of the result, so you have omitted some of the story (the part 
where you made an error, I think).

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list