[R] NA points in loess function

Yao, Minghua yao6889 at msmailhub.oulan.ou.edu
Fri Jun 27 21:07:30 CEST 2003


Thank you, Prof. Ripley. By adding na.action=na.exclude to loess function,
the program runs great. 

I did omit some trivial things. But I still think it was NA's that caused
troubles in predict or loess.

Minghua 

-----Original Message-----
From: Prof Brian Ripley [mailto:ripley at stats.ox.ac.uk]
Sent: Friday, June 27, 2003 11:05 AM
To: Yao, Minghua
Cc: R Help (E-mail)
Subject: Re: [R] NA points in loess function


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