On 3/21/19 3:31 PM, reichm...@sbcglobal.net wrote:
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))
I just looked up the usage on `length` and do not see any possibility of using a "replace" parameter. It's also unclear what sort of data object `myData` might be. (And you might consider using column names other than the names of R functions.)
-- David.
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.
______________________________________________ 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.