[R-gregmisc-commits] r2036 - pkg/gtools/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed May 27 02:20:42 CEST 2015
Author: warnes
Date: 2015-05-27 02:20:42 +0200 (Wed, 27 May 2015)
New Revision: 2036
Modified:
pkg/gtools/R/roman2int.R
Log:
roman2int() now returns NA for invalid roman numeral strings instead of generating an error.
Modified: pkg/gtools/R/roman2int.R
===================================================================
--- pkg/gtools/R/roman2int.R 2015-05-27 00:19:41 UTC (rev 2035)
+++ pkg/gtools/R/roman2int.R 2015-05-27 00:20:42 UTC (rev 2036)
@@ -31,7 +31,18 @@
roman2int <- function(roman)
{
roman <- trim(toupper(as.character(roman)))
- retval <- sapply(roman, roman2int.inner)
+
+ tryIt <- function(x)
+ {
+ retval <- try(roman2int.inner(x), silent=TRUE)
+ if(is.numeric(retval))
+ retval
+ else
+ NA
+ }
+
+ retval <- sapply(roman, tryIt)
+
retval
}
More information about the R-gregmisc-commits
mailing list