[Phylobase-commits] r807 - pkg/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Aug 4 17:34:33 CEST 2010
Author: francois
Date: 2010-08-04 17:34:33 +0200 (Wed, 04 Aug 2010)
New Revision: 807
Modified:
pkg/R/readNCL.R
Log:
Improved handling of missing state labels with option return.labels
Modified: pkg/R/readNCL.R
===================================================================
--- pkg/R/readNCL.R 2010-08-04 13:10:18 UTC (rev 806)
+++ pkg/R/readNCL.R 2010-08-04 15:34:33 UTC (rev 807)
@@ -77,8 +77,16 @@
tipData[[i]] <- eval(parse(text=ncl$dataChr[i]))
names(tipData)[i] <- ncl$charLabels[i]
tipData[[i]] <- as.factor(tipData[[i]])
+
+ lbl <- ncl$stateLabels[lblCounter]
if (return.labels) {
- levels(tipData[[i]]) <- ncl$stateLabels[lblCounter]
+ if (any(nchar(gsub(" ", "", lbl)) == 0)) {
+ warning("state labels are missing for \'", ncl$charLabels[i],
+ "\', the option return.labels is thus ignored.")
+ }
+ else {
+ levels(tipData[[i]]) <- lbl
+ }
}
}
if (levels.uniform) {
More information about the Phylobase-commits
mailing list