Count distinct in a rxSummary
问题 I want to count distinct values of var2 grouping by var1 in a .xdf file, I tried something like this myFun <- function(dataList) { UniqueLevel <<- unique(c(UniqueLevel, dataList$var2)) SumUniqueLevel <<- length(UniqueLevel) return(NULL) } rxSummary(formula = ~ var1, data = "DefModelo2.xdf", transformFunc = myFun, transformObjects = list(UniqueLevel = NULL), removeZeroCounts = F) Thank you in advance EDIT: Probably using RevoPemaR is the the faster way 回答1: One other option is to use