From tdhock5 @end|ng |rom gm@||@com  Thu Aug 12 07:16:06 2021
From: tdhock5 @end|ng |rom gm@||@com (Toby Hocking)
Date: Wed, 11 Aug 2021 22:16:06 -0700
Subject: [Rd] na.omit inconsistent with is.na on list
In-Reply-To: <CALK03d0vRmxNLzyU-s8O1Urg6yneYZeSKtdRizx5Z=ZZ57Fdcg@mail.gmail.com>
References: <CALK03d0vRmxNLzyU-s8O1Urg6yneYZeSKtdRizx5Z=ZZ57Fdcg@mail.gmail.com>
Message-ID: <CALK03d0pPSy5CL2AHZMtso5_7uXW5NfxZfC+mUsMm8yo8rOViA@mail.gmail.com>

Also, the na.omit method for data.frame with list column seems to be
inconsistent with is.na,

> L <- list(NULL, NA, 0)
> str(f <- data.frame(I(L)))
'data.frame': 3 obs. of  1 variable:
 $ L:List of 3
  ..$ : NULL
  ..$ : logi NA
  ..$ : num 0
  ..- attr(*, "class")= chr "AsIs"
> is.na(f)
         L
[1,] FALSE
[2,]  TRUE
[3,] FALSE
> na.omit(f)
   L
1
2 NA
3  0

On Wed, Aug 11, 2021 at 9:58 PM Toby Hocking <tdhock5 at gmail.com> wrote:

> na.omit is documented as "na.omit returns the object with incomplete cases
> removed." and "At present these will handle vectors," so I expected that
> when it is used on a list, it should return the same thing as if we subset
> via is.na; however I observed the following,
>
> > L <- list(NULL, NA, 0)
> > str(L[!is.na(L)])
> List of 2
>  $ : NULL
>  $ : num 0
> > str(na.omit(L))
> List of 3
>  $ : NULL
>  $ : logi NA
>  $ : num 0
>
> Should na.omit be fixed so that it returns a result that is consistent
> with is.na? I assume that is.na is the canonical definition of what
> should be considered a missing value in R.
>

	[[alternative HTML version deleted]]



[Rd] na.omit inconsistent with is.na on list
Toby Hocking