X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=R%2Fread.nexus.R;h=01aec6495d560e7dc5ef15386f062941ad0e2af0;hb=de88c4801a78a3d1a8376c19be8c852727eeaf09;hp=cbf0f20e7a42ff1bc6bd2c90090c695477995f47;hpb=45da26e7c3c483aee0781f799da5ef336f14a028;p=ape.git diff --git a/R/read.nexus.R b/R/read.nexus.R index cbf0f20..01aec64 100644 --- a/R/read.nexus.R +++ b/R/read.nexus.R @@ -1,4 +1,4 @@ -## read.nexus.R (2008-09-17) +## read.nexus.R (2008-11-24) ## Read Tree File in Nexus Format @@ -153,6 +153,8 @@ read.nexus <- function(file, tree.names = NULL) tree <- X[start:end] rm(X) tree <- gsub("^.*= *", "", tree) + ## check whether there are empty lines from the above manips: + tree <- tree[tree == ""] semico <- grep(";", tree) Ntree <- length(semico) ## are some trees on several lines? @@ -161,8 +163,13 @@ read.nexus <- function(file, tree.names = NULL) STRING <- character(Ntree) s <- c(1, semico[-Ntree] + 1) j <- mapply(":", s, semico) - for (i in 1:Ntree) - STRING[i] <- paste(tree[j[, i]], collapse = "") + if (is.list(j)) { + for (i in 1:Ntree) + STRING[i] <- paste(tree[j[[i]]], collapse = "") + } else { + for (i in 1:Ntree) + STRING[i] <- paste(tree[j[, i]], collapse = "") + } } else STRING <- tree } rm(tree)