r-help I have the following little scrip to create a df of summary stats. I'm having problems obtaining the # of unique values
unique=sapply(myData, function (x) length(unique(x), replace = TRUE)) Can I do that, or am I using the wrong R function? summary.stats <- data.frame(mean=sapply(myData, mean, na.rm=TRUE), sd=sapply(myData, sd, na.rm=TRUE), min=sapply(myData, min, na.rm=TRUE), max=sapply(myData, max, na.rm=TRUE), median=sapply(myData, median, na.rm=TRUE), length=sapply(myData, length), unique=sapply(myData, function (x) length(unique(x), replace = TRUE)) miss.val=sapply(myData, function(y) sum(length(which(is.na(y)))))) Jeff Reichman ______________________________________________ R-help@r-project.org 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.