Re: [R] count NAs per week

2012-09-18 Thread Tagmarie
Thank you Arun, that was exactly what I was looking for. This is the second time you helped me in this mailing list. Thanks! And also thanks to all of the others of you whou helped me. It is amazing how many possibilities there are to solve my problem (which isn't a prob now anymore). Have a gre

Re: [R] count NAs per week

2012-09-17 Thread David Winsemius
On Sep 17, 2012, at 6:07 AM, Tagmarie wrote: > Thank you Michael, that worked perfectly! > > Now I wonder, if it is possible to break my data further apart and put it > together again. > Assume I include a column for an ID in the data frame like this: > > dattrial2<-data.frame(a=c(1,NA,NA,NA

Re: [R] count NAs per week

2012-09-17 Thread arun
4   Ernie 0 A.K. - Original Message - From: Tagmarie To: r-help@r-project.org Cc: Sent: Monday, September 17, 2012 9:07 AM Subject: Re: [R] count NAs per week Thank you Michael, that worked perfectly! Now I wonder, if it is possible to break my data further apart and put it together

Re: [R] count NAs per week

2012-09-17 Thread Tagmarie
Thank you Michael, that worked perfectly! Now I wonder, if it is possible to break my data further apart and put it together again. Assume I include a column for an ID in the data frame like this: dattrial2<-data.frame(a=c(1,NA,NA,NA,2,3), Week=c(3,3,3,4,4,4), AnimalID=c("Ernie","Bert", "Ernie

Re: [R] count NAs per week

2012-09-17 Thread arun
Hi, Try this: dattrial<-data.frame(a=c(1,NA,rnorm(4,10)), Week=c(3,3,3,4,4,4))  aggregate(dattrial$a,list(dattrial$Week),function(x) sum(is.na(x))) #  Group.1 x #1   3 1 #2   4 0 #or  ddply(dattrial,.(Week),summarize, sum(is.na(a))) #  Week ..1 #1    3   1 #2    4   0 #or list1<-split(dat

Re: [R] count NAs per week

2012-09-17 Thread William Dunlap
> 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

Re: [R] count NAs per week

2012-09-17 Thread R. Michael Weylandt
On Mon, Sep 17, 2012 at 11:03 AM, Tagmarie wrote: > 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<