Skip to content

Commit

Permalink
Minor change to bd.sim.traits to make sure it doesn't bug when ran wi…
Browse files Browse the repository at this point in the history
…th multiple traits.
  • Loading branch information
brpetrucci committed Jul 18, 2023
1 parent 63d1de9 commit e6ad375
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion R/bd.sim.traits.R
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ bd.sim.traits <- function(n0, lambda, mu,
# if there are hidden states
if (nHidden[tr] > 1) {
# set them to normal states
traitsSp$value <- traitsSp$value %% nStates
traitsSp$value <- traitsSp$value %% nStates[tr]

if (nrow(traitsSp) > 1) {
# duplicate rows
Expand Down
6 changes: 3 additions & 3 deletions R/traits.summary.R
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ traits.summary <- function(sim, traits, fossils = NULL, selection = "all") {

# create final list return
res <- vector(mode = "list", length = length(traits[[1]]))

# iterate through traits
for (t in 1:length(traits[[1]])) {
# create return
Expand All @@ -159,7 +159,7 @@ traits.summary <- function(sim, traits, fossils = NULL, selection = "all") {
# add name and status
traitNames <- c(traitNames, paste0("t", sp))
traitStatus <- c(traitStatus, c("extinct", "extant")[sim$EXTANT[sp] + 1])

# check whether we need to go through fossils or not
if (!is.null(fossils) && sum(fossils$Species == paste0("t", sp)) > 0) {
# select fossil rows that are for this species
Expand All @@ -184,7 +184,7 @@ traits.summary <- function(sim, traits, fossils = NULL, selection = "all") {
}
}
}

# name traitList
names(traitList) <- traitNames

Expand Down

0 comments on commit e6ad375

Please sign in to comment.