View | Details | Raw Unified | Return to bug 16640 | Differences between
and this patch

Collapse All | Expand All

(-)tapply.R (-2 / +4 lines)
Lines 39-46 Link Here
39
	ngroup <- ngroup * nlevels(index)
39
	ngroup <- ngroup * nlevels(index)
40
    }
40
    }
41
    if (is.null(FUN)) return(group)
41
    if (is.null(FUN)) return(group)
42
    ans <- lapply(X = split(X, group), FUN = FUN, ...)
42
    levels(group) <- as.character(seq_len(ngroup))
43
    index <- as.integer(names(ans))
43
    class(group) <- "factor"
44
    index <- which(lengths(ans <- split(X, group)) > 0L)
45
    ans <- lapply(X = ans[index], FUN = FUN, ...)
44
    if (simplify && all(lengths(ans) == 1L)) {
46
    if (simplify && all(lengths(ans) == 1L)) {
45
	ansmat <- array(dim = extent, dimnames = namelist)
47
	ansmat <- array(dim = extent, dimnames = namelist)
46
	ans <- unlist(ans, recursive = FALSE)
48
	ans <- unlist(ans, recursive = FALSE)

Return to bug 16640