Umm ...

On Mon, Aug 25, 2008 at 2:56 PM, jim holtman <jholtman@gmail.com> wrote:

> The only problem with this solution is what happens if the element has
> more than one NA:
>
> [...]
>

In that case, 'b' does not have the right answer.  That was the reason
> for using 'all' to check for the condition:
>
> > unlist(sapply(lt, function(x) all(is.na(x[1]))))
>    a     b     c     d
> FALSE  TRUE FALSE  TRUE
>


1. Unlist is unnecessary here (sapply automatically simplifies its result).
2. Why use all() with one-element vector (x[1])?

So I assume that what you meant is actually something like this:

sapply(lt, function(x) all(is.na(x)))


Kenn

>
>
>
> On Mon, Aug 25, 2008 at 3:33 AM, Kenn Konstabel <lebatsnok@gmail.com>
> wrote:
> > lt[!is.na(lt)] is a rather obvious way...
> >
> >
> > On Fri, Aug 22, 2008 at 9:41 PM, Dong-hyun Oh <oh.dongh@gmail.com>
> wrote:
> >
> >> Dear useRs,
> >>
> >> I would like to know the way of deleting NA in list().
> >>
> >> Following is a example.
> >>
> >> lt <- list(a = 1:3, b = NA, c = letters[1:3], d = NA)
> >>
> >> for(i in length(lt):1) {
> >>        if(is.na(lt[[i]])) lt[[i]] <- NULL
> >> }
> >>
> >> How to simplify for() loop by using (l)apply family?
> >>
> >> Thank you in advance.
> >>
> >>
> >>
> >>
> >> =========================================================
> >> Dong-hyun Oh
> >> Center of Excellence for Science and Innovation Studies
> >> Royal Institute or Technology, Sweden
> >> e-mail: oh.dongh@gmail.com
> >> cel: +46 73 563 45 22
> >>
> >> ______________________________________________
> >> R-help@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.
> >>
> >
> >        [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-help@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.
> >
>
>
>
> --
> Jim Holtman
> Cincinnati, OH
> +1 513 646 9390
>
> What is the problem that you are trying to solve?
>

	[[alternative HTML version deleted]]

