[R] count NAs per week

David Winsemius dwinsemius at comcast.net
Mon Sep 17 19:52:44 CEST 2012


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,2,3), Week=c(3,3,3,4,4,4),
> AnimalID=c("Ernie","Bert", "Ernie", "Bert", "Bert", "Ernie"))
> 
> Is it possible to get two different lists in the output, one for Ernie and
> one for Bert? Or do I have to do it seperately for each animal?

split(dattrial2, dattrial2[['AnimalID']])

> 
> Thank you again! I learn a lot by doing and by people helping me. Thank you
> for the hint with the paper. 
> 
> 
> 
> 
> 
> --
> View this message in context: http://r.789695.n4.nabble.com/count-NAs-per-week-tp4643351p4643371.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> R-help at 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.

David Winsemius, MD
Alameda, CA, USA




More information about the R-help mailing list