>>>>> Bert Gunter <bgunter.4...@gmail.com> >>>>> on Mon, 2 May 2016 06:20:52 -0700 writes:
> Martin et. al.: > na.omit(frame) will remove all rows/cases in which an NA occurs. I'm > not sure that this is what the OP wanted, which seemed to be to > separately remove NA's from each column and plot the resulting column. > This is what the lapply (and the OP's provided code) does, anyway. > Also, lapply() produces a single list (of vectors), not a "series of lists" . > Corrections happily accepted if I'm in error. No corrections needed. You were right ... and indeed I was wrong in assuming that "one would want" a complete na.omit() here. Martin > Cheers, > Bert > Bert Gunter > "The trouble with having an open mind is that people keep coming along > and sticking things into it." > -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) > On Mon, May 2, 2016 at 1:49 AM, Martin Maechler > <maech...@stat.math.ethz.ch> wrote: >>>>>>> Mike Smith <m...@hsm.org.uk> >>>>>>> on Sun, 1 May 2016 08:15:44 +0100 writes: >> >> >>>> On Apr 30, 2016, at 12:58 PM, Mike Smith >> >>>> <m...@hsm.org.uk> wrote: Hi >> >> >>>> First post and a relative R newbie.... >> >> >>>> I am using the vioplot library to produce some violin >> >>>> plots. >> DW> It's a package, .... not a library. >> >> [yes!] >> >> >> >>>> 1. Is there a more elegant way of automatically >> >>>> stripping the NAs, passing the columns to the function >> >>>> along with the header names?? >> >> >>> ds2 <- lapply( ds1, na.omit) >> >> >> > Fantastic - that does the trick! Easy when you know how!! >> >> > Follow-on: is there a way feed all the lists from ds2 to >> > vioplot? It is now a series of lists (rather than a >> > dataframe - is that right?). >> >> Yes, that's right. So after all the above was not really >> perfect : >> >> na.omit() has been designed as a generic function and has always >> had a method for "data.frame"; so, really >> >> ds.noNA <- na.omit(ds1) >> or ds0NA <- na.omit(ds1) >> >> (choosing "expressive names") >> >> is what you want. >> >> ______________________________________________ >> R-help@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. ______________________________________________ R-help@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.