[Rcpp-commits] r3373 - pkg/int64/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Nov 17 08:19:33 CET 2011


Author: romain
Date: 2011-11-17 08:19:30 +0100 (Thu, 17 Nov 2011)
New Revision: 3373

Modified:
   pkg/int64/R/int64.R
Log:
NA warning were introduced where they should not have

Modified: pkg/int64/R/int64.R
===================================================================
--- pkg/int64/R/int64.R	2011-11-16 11:42:10 UTC (rev 3372)
+++ pkg/int64/R/int64.R	2011-11-17 07:19:30 UTC (rev 3373)
@@ -102,15 +102,21 @@
 
 as.int64 <- function(x){
     if( is.character(x) ){
-        x[ ! grepl("^[-]?[0-9]+$", x) ] <- NA
-        warning( "NAs introduced" ) 
+        wrong <- ! grepl("^[-]?[0-9]+$", x) 
+        if( any(wrong) ){
+            x[wrong] <- "NA"
+            warning( "NAs introduced" )
+        }
     }
     new( "int64", .Call(int64_as_int64, x) ) 
 }
 as.uint64 <- function(x){
     if( is.character(x) ){
-        x[ ! grepl("^[-]?[0-9]+$", x) ] <- NA
-        warning( "NAs introduced" )
+        wrong <- ! grepl("^[0-9]+$", x) 
+        if( any(wrong) ){
+            x[wrong] <- "NA"
+            warning( "NAs introduced" )
+        }
     }
     new( "uint64", .Call(int64_as_uint64, x) ) 
 }



More information about the Rcpp-commits mailing list