On Tue, Apr 19, 2011 at 03:29:08PM +0800, Tim Elwell-Sutton wrote: > Dear all > > > > I have written a function to perform a very simple but useful task which I > do regularly. It is designed to show how many values are missing from each > variable in a data.frame. In its current form it works but is slow because I > have used several loops to achieve this simple task.
Why not use summary? > foo <- data.frame(a=c(1,3,4,NA), b=c(NA,4,NA,8), c=factor(c('A', NA, 'A', > 'B'))) > summary(foo) a b c Min. :1.000 Min. :4 A :2 1st Qu.:2.000 1st Qu.:5 B :1 Median :3.000 Median :6 NA's:1 Mean :2.667 Mean :6 3rd Qu.:3.500 3rd Qu.:7 Max. :4.000 Max. :8 NA's :1.000 NA's :2 cu Philipp -- Dr. Philipp Pagel Lehrstuhl für Genomorientierte Bioinformatik Technische Universität München Wissenschaftszentrum Weihenstephan Maximus-von-Imhof-Forum 3 85354 Freising, Germany http://webclu.bio.wzw.tum.de/~pagel/ ______________________________________________ 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.