Dear Rxperts,
q <- data.frame(p=rep(c("A","B"),each=10,len=30),
a=rep(c(1,2,3),each=10),id=seq(30),
b=round(runif(30,10,20)),
c=round(runif(30,40,70)))
The operation below...
tabular(((p=factor(p))*(a=factor(a))+1) ~ (N = 1) + (b + c)*
(mean+sd),data=q)
yields some rows of NAs and NaN as shown below

             b               c
 p a   N  mean  sd    mean  sd
 A 1   10 16.30 2.497 52.30  9.358
   2    0   NaN    NA   NaN     NA
   3   10 15.60 2.716 60.30  8.001
 B 1    0   NaN    NA   NaN     NA
   2   10 15.40 2.366 57.70 10.414
   3    0   NaN    NA   NaN     NA
   All 30 15.77 2.473 56.77  9.601

How do I remove the rows having N=0 ?
I would like the resulting table look like..
             b               c
 p a   N  mean  sd    mean  sd
 A 1   10 16.30 2.497 52.30  9.358
     3   10 15.60 2.716 60.30  8.001
 B  2   10 15.40 2.366 57.70 10.414
   All 30 15.77 2.473 56.77  9.601

Thanks so much,
Santosh

        [[alternative HTML version deleted]]

______________________________________________
[email protected] 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.

Reply via email to