> with(dattrial, table(A_is_missing=is.na(a), Week)) Week A_is_missing 3 4 FALSE 2 3 TRUE 1 0 > with(dattrial, table(A_is_missing=is.na(a), Week))["TRUE", ] # extract the > missing="TRUE" row, note quotes 3 4 1 0
Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -----Original Message----- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf > Of Tagmarie > Sent: Monday, September 17, 2012 3:03 AM > To: r-help@r-project.org > Subject: [R] count NAs per week > > Even though I work with R since a year or so I still struggle with simple > problems. I hope someone can help me with this. Been trying for days and am > a little frustrated now. > > I have a data frame somewhat like the one bellow: > > dattrial<-data.frame(a=c(1,NA,rnorm(4,10)), Week=c(3,3,3,4,4,4)) > > I want to know how many NAs I have in week 3 and in week 4. > > > > -- > View this message in context: > http://r.789695.n4.nabble.com/count-NAs-per-week- > tp4643351.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. ______________________________________________ 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.