[R] Handling NA's when you write your own code

Ott Toomet otoomet at gmail.com
Wed Sep 9 21:51:31 CEST 2015


Not quite sure what you mean with "dealing with NAs in use-specific code".

Some functions handle these automatically, like lm().  If you write your
own code, and want to handle NA-s somehow, you have to implement such
checks yourself.  You may also use the "complete.cases" function (but that
does not detect Inf-s).

Typically your own handling means excluding NA-s in one way or another as
most of the math operations are not defined on these.

Cheers,
Ott

On Wed, Sep 9, 2015 at 12:03 PM, Olu Ola via R-help <r-help at r-project.org>
wrote:

> Hello,
> I have a dataset that have a couple of missing values and I DO NOT want to
> delete the observations with the missing values. I have read about
> na.action in dealing with missing values but I do not know how it applies
> to user-specific written code.
>
> Is there a code you can use with your dataset so that subsequent analysis
> will automatically detect missing values?
>
> The following are some of the things I will be doing so that you can
> advice me appropriately
>
> Computing OLS estimates using the matrix approach
> Write objective and gradient function subroutines which will now be used
> in the Optimx for nonlinear optimization.
>
> Thank you
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
>



-- 
Ott Toomet

Visiting Researcher
School of Information
Mary Gates Hall, Suite 310
University of Washington
Seattle, WA 98195

	[[alternative HTML version deleted]]



More information about the R-help mailing list