X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=R%2FrTrait.R;h=ec055dcb58a643798cc51976938cc1e19ff4f6af;hb=d5b85d181648e2761cecc91d75c4c66fa05e4508;hp=2c04dc6dd0855e246de03107d4b70017386baab3;hpb=f295ab19440298e543db5a270e54f10a84382197;p=ape.git diff --git a/R/rTrait.R b/R/rTrait.R index 2c04dc6..ec055dc 100644 --- a/R/rTrait.R +++ b/R/rTrait.R @@ -1,8 +1,8 @@ -## rTrait.R (2010-07-26) +## rTrait.R (2011-04-02) ## Trait Evolution -## Copyright 2010 Emmanuel Paradis +## Copyright 2010-2011 Emmanuel Paradis ## This file is part of the R-package `ape'. ## See the file ../COPYING for licensing issues. @@ -10,7 +10,7 @@ rTraitDisc <- function(phy, model = "ER", k = if (is.matrix(model)) ncol(model) else 2, rate = 0.1, states = LETTERS[1:k], freq = rep(1/k, k), - ancestor = FALSE, root.value = 1) + ancestor = FALSE, root.value = 1, ...) { if (is.null(phy$edge.length)) stop("tree has no branch length") @@ -56,7 +56,7 @@ rTraitDisc <- if (is.function(model)) { environment(model) <- environment() # to find 'k' - for (i in N:1) x[des[i]] <- model(x[anc[i]], el[i]) + for (i in N:1) x[des[i]] <- model(x[anc[i]], el[i], ...) } else { freq <- rep(freq, each = k) Q <- Q * freq @@ -82,7 +82,7 @@ rTraitDisc <- rTraitCont <- function(phy, model = "BM", sigma = 0.1, alpha = 1, theta = 0, - ancestor = FALSE, root.value = 0, linear = TRUE) + ancestor = FALSE, root.value = 0, linear = TRUE, ...) { if (is.null(phy$edge.length)) stop("tree has no branch length") @@ -102,7 +102,7 @@ rTraitCont <- if (is.function(model)) { environment(model) <- environment() - for (i in N:1) x[des[i]] <- model(x[anc[i]], el[i]) + for (i in N:1) x[des[i]] <- model(x[anc[i]], el[i], ...) } else { model <- pmatch(toupper(model), c("BM", "OU")) if (length(sigma) == 1) sigma <- rep(sigma, N) @@ -117,7 +117,10 @@ rTraitCont <- stop("'theta' must have one or Nedge(phy) elements") if (!linear) model <- model + 1L } - .C("rTraitCont", as.integer(model), as.integer(N), as.integer(anc - 1L), as.integer(des - 1L), el, sigma, alpha, theta, x, DUP = FALSE, NAOK = TRUE, PACKAGE = "ape") + .C("rTraitCont", as.integer(model), as.integer(N), + as.integer(anc - 1L), as.integer(des - 1L), el, + as.double(sigma), as.double(alpha), as.double(theta), x, + DUP = FALSE, NAOK = TRUE, PACKAGE = "ape") } if (ancestor) {