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

Collapse All | Expand All

(-)tapply.R (-3 / +3 lines)
Lines 41-48 Link Here
41
    class(group) <- "factor"
41
    class(group) <- "factor"
42
    ans <- split(X, group) # use generic, e.g. for 'Date'
42
    ans <- split(X, group) # use generic, e.g. for 'Date'
43
    names(ans) <- NULL
43
    names(ans) <- NULL
44
    index <- as.logical(lengths(ans))  # equivalently, lengths(ans) > 0L
44
    group <- as.logical(lengths(ans))  # index; equivalently, lengths(ans) > 0L
45
    ans <- lapply(X = ans[index], FUN = FUN, ...)
45
    ans <- lapply(X = ans[group], FUN = FUN, ...)
46
    if (simplify && all(lengths(ans) == 1L)) {
46
    if (simplify && all(lengths(ans) == 1L)) {
47
	ansmat <- array(dim = extent, dimnames = namelist)
47
	ansmat <- array(dim = extent, dimnames = namelist)
48
	ans <- unlist(ans, recursive = FALSE)
48
	ans <- unlist(ans, recursive = FALSE)
Lines 51-57 Link Here
51
			dim = extent, dimnames = namelist)
51
			dim = extent, dimnames = namelist)
52
    }
52
    }
53
    if(length(ans)) {
53
    if(length(ans)) {
54
	ansmat[index] <- ans
54
	ansmat[group] <- ans
55
    }
55
    }
56
    ansmat
56
    ansmat
57
}
57
}

Return to bug 16640