[R] NAs spoil lowess smoothing

Thomas Lumley thomas at biostat.washington.edu
Thu Jan 28 19:30:55 CET 1999

On Thu, 28 Jan 1999, Stuart Luppescu wrote:

> Can anyone explain to me what this error message means, why I'm getting it, and
> how to fix it?
>  lines(lowess(xdat, ydat, f=.5), col=3)
> Error: NAs in foreign function call (arg 1)

It means that in a call to .C or .Fortran there are missing values in the 
first argument. The call to .C is inside lowess(), and its first argument
is the x data. So you're getting it because there are NAs in xdat.

You can fix it by removing the NAs, eg
	good<-!(is.na(xdat) | is.na(ydat))

Refusing to handle NAs is the usual default behaviour of functions. Some
functions have na.action= arguments to control this, but lowess doesn't.

Thomas Lumley
Assistant Professor, Biostatistics
University of Washington, Seattle

r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch

More information about the R-help mailing list