- if (is.list(x)) x <- unlist(x)
- n <- length(x)
- BF <-.C("BaseProportion", x, as.integer(n), double(17),
- DUP = FALSE, NAOK = TRUE, PACKAGE = "ape")[[3]]
+ f <- function(x)
+ .C("BaseProportion", x, as.integer(length(x)), double(17),
+ DUP = FALSE, NAOK = TRUE, PACKAGE = "ape")[[3]]
+
+ if (is.list(x)) {
+ BF <- rowSums(sapply(x, f))
+ n <- sum(sapply(x, length))
+ } else {
+ n <- length(x)
+ BF <-.C("BaseProportion", x, as.integer(n), double(17),
+ DUP = FALSE, NAOK = TRUE, PACKAGE = "ape")[[3]]
+ }
+