Hi, Could you try rbind.na.R function. karim Ô__ c/ /'_;~~~~kmezhoud (*) \(*) ⴽⴰⵔⵉⵎ ⵎⴻⵣⵀⵓⴷ http://bioinformatics.tn/
On Wed, Dec 10, 2014 at 10:34 PM, Raffaello Vardavas <[email protected] > wrote: > Dear All, > > I have a data fame. Each column has numerical values but some columns may > have NA values. > I'd like a table showing the summary statistics for each column. This is > what I do: > > I first do the following: > > apply(df[,metrics],2,summary,na.rm=T) > > giving: > > $degree > Min. 1st Qu. Median Mean 3rd Qu. Max. > 0.0 261.9 489.3 500.6 698.5 1551.0 > > $EV.centrality > Min. 1st Qu. Median Mean 3rd Qu. Max. > 0.0000000 0.0001067 0.0006391 0.0057460 0.0020410 1.0000000 > > $betweenness > Min. 1st Qu. Median Mean 3rd Qu. Max. > 0.0 0.0 150.5 2955.0 2208.0 60940.0 > > $knn > Min. 1st Qu. Median Mean 3rd Qu. Max. NA's > 2.00 21.50 32.44 36.75 46.15 224.50 26 > > > Then I rbind them and get: > > do.call("rbind",apply(df[,metrics],2,summary,na.rm=T)) > > Min. 1st Qu. Median Mean 3rd Qu. > Max. NA's > degree 0 2.619e+02 4.893e+02 5.006e+02 6.985e+02 > 1551.0 0 > EV.centrality 0 1.067e-04 6.391e-04 5.746e-03 2.041e-03 > 1.0 0 > betweenness 0 0.000e+00 1.505e+02 2.955e+03 2.208e+03 > 60940.0 0 > knn 2 2.150e+01 3.244e+01 3.675e+01 4.615e+01 > 224.5 26 > > Since the first 3 rows don't have NA's but the 4th has I get the following > warning: > > Warning message: > In rbind(degree = c(0, 261.9, 489.3, 500.6, 698.5, 1551), EV.centrality = > c(0, : > number of columns of result is not a multiple of vector length (arg 1) > Calls: do.call -> rbind > > > How do I code this in a way to avoid this warning? > > Thanks. > > Raff > > [[alternative HTML version deleted]] > > ______________________________________________ > [email protected] 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. > ______________________________________________ [email protected] 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.

