| 1 |
|
| 2 |
# .memberDend ------------------------------------------------------------- |
| 3 |
|
| 4 |
### Code copied from stats:::.memberDend |
| 5 |
|
| 6 |
.memberDend <- function(x) { |
| 7 |
r <- attr(x, "x.member") |
| 8 |
if (is.null(r)) { |
| 9 |
r <- attr(x, "members") |
| 10 |
if (is.null(r)) { |
| 11 |
r <- 1L |
| 12 |
} |
| 13 |
} |
| 14 |
r |
| 15 |
} |
| 16 |
|
| 17 |
|
| 18 |
# plotNodeLimit ----------------------------------------------------------- |
| 19 |
|
| 20 |
### Code copied from stats:::plotNodeLimit |
| 21 |
|
| 22 |
plotNodeLimit <- function(x1, x2, subtree, center) { |
| 23 |
inner <- !is.leaf(subtree) && x1 != x2 |
| 24 |
if (inner) { |
| 25 |
K <- length(subtree) |
| 26 |
mTop <- .memberDend(subtree) |
| 27 |
limit <- integer(K) |
| 28 |
xx1 <- x1 |
| 29 |
for (k in 1L:K) { |
| 30 |
m <- .memberDend(subtree[[k]]) |
| 31 |
xx1 <- xx1 + (if (center) { |
| 32 |
(x2 - x1) * m / mTop |
| 33 |
} else { |
| 34 |
m |
| 35 |
}) |
| 36 |
limit[k] <- xx1 |
| 37 |
} |
| 38 |
limit <- c(x1, limit) |
| 39 |
} |
| 40 |
else { |
| 41 |
limit <- c(x1, x2) |
| 42 |
} |
| 43 |
mid <- attr(subtree, "midpoint") |
| 44 |
center <- center || (inner && !is.numeric(mid)) |
| 45 |
x <- if (center) { |
| 46 |
mean(c(x1, x2)) |
| 47 |
} else { |
| 48 |
x1 + (if (inner) { |
| 49 |
mid |
| 50 |
} else { |
| 51 |
0 |
| 52 |
}) |
| 53 |
} |
| 54 |
list(x = x, limit = limit) |
| 55 |
} |
| 56 |
|
| 57 |
# .midDend -------------------------------------------------------------------- |
| 58 |
|
| 59 |
### Code copied from stats:::.midDend |
| 60 |
|
| 61 |
|
| 62 |
.midDend <- function(x) { |
| 63 |
if (is.null(mp <- attr(x, "midpoint"))) 0 else mp |
| 64 |
} |