Message-ID: <1D7DB03F-C03B-48E4-B508-6C23406F26A2@comcast.net>
Date: 2016-04-30T23:16:11Z
From: David Winsemius
Subject: Removing NAs from dataframe (for use in Vioplot)
In-Reply-To: <142423783.20160430205840@hsm.org.uk>
> On Apr 30, 2016, at 12:58 PM, Mike Smith <mike at hsm.org.uk> wrote:
>
> Hi
>
> First post and a relative R newbie....
>
> I am using the vioplot library to produce some violin plots. I have an input CSV with columns off irregular length that contain NAs. I want to strip the NAs out and produce a multiple violin plot automatically labelled using the headers. At the moment I do this
>
> Code:
> ds1 = read.csv("http://www.lecturematerials.co.uk/data/spelling.csv")
> library(vioplot)
> y6<-na.omit(ds1$y6)
> y5<-na.omit(ds1$y5)
> y4<-na.omit(ds1$y4)
> y3<-na.omit(ds1$y3)
> y2<-na.omit(ds1$y2)
> y1<-na.omit(ds1$y1)
> vioplot(y6, y5, y4,y3,y2,y1,horizontal=TRUE, names=c("Y6", "Y5","Y4","Y3","Y2","Y1"), col = "lightblue")
>
>
> Two queries:
>
> 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)
> 2. Can I easily add the sample size to each violin plotted??
> ?violplot
No documentation for ?violplot? in specified packages and libraries:
you could try ???violplot?
>
> thanks
>
> mike
>
>
>
> ---
> Mike Smith
>
> ______________________________________________
> 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.
David Winsemius
Alameda, CA, USA