[R] problem with NA and if

From: Keld Jørn Simonsen <keld_at_dkuug.dk>
Date: Fri, 04 Jul 2008 08:29:34 +0200


I would like to sum a number of time series, some of them having NA's

Standard action is here that if I sum a value with a NA, then the result is NA. I would like it to just keep the value.

I then try to:

 a = NA; if (a == NA) { a = 0}

just to try it out, but it says

Error in if (a == NA) { : missing value where TRUE/FALSE needed

What is wrong, and can I do it smarter? I looked at na.action but I don't see how it affects addition of vectors, nor time series.

Best regards

R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Fri 04 Jul 2008 - 06:33:16 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 04 Jul 2008 - 07:31:24 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive