[R-gregmisc-commits] r2071 - pkg/gtools/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Nov 24 18:58:03 CET 2015
Author: warnes
Date: 2015-11-24 18:58:02 +0100 (Tue, 24 Nov 2015)
New Revision: 2071
Modified:
pkg/gtools/R/smartbind.R
Log:
Correct error when column types don't match (reported by
Modified: pkg/gtools/R/smartbind.R
===================================================================
--- pkg/gtools/R/smartbind.R 2015-11-23 18:22:55 UTC (rev 2070)
+++ pkg/gtools/R/smartbind.R 2015-11-24 17:58:02 UTC (rev 2071)
@@ -69,32 +69,30 @@
levels(block[,col])
}
- if( !(col %in% names(retval)))
+ if(verbose) cat("Start:", start,
+ " End:", end,
+ " Column:", col,
+ "\n", sep="")
+
+ if ("factor" %in% classVec)
{
- if(verbose) cat("Start:", start,
- " End:", end,
- " Column:", col,
- "\n", sep="")
+ newclass <- "character"
+ }
+ else
+ newclass <- classVec[1]
- if ("factor" %in% classVec)
- {
+ ## Coerce everything that isn't a native type to character
+ if(! (newclass %in% c("logical", "integer", "numeric",
+ "complex", "character", "raw") ))
+ {
newclass <- "character"
- }
- else
- newclass <- classVec[1]
+ warning("Converting non-atomic type column '", col,
+ "' to type character.")
+ }
- ## Coerce everything that isn't a native type to character
- if(! (newclass %in% c("logical", "integer", "numeric",
- "complex", "character", "raw") ))
- {
- newclass <- "character"
- warning("Converting non-atomic type column '", col,
- "' to type character.")
- }
+ if(! (col %in% names(retval) ) )
+ retval[[col]] <- as.vector(rep(fill,nrows), mode=newclass)
- retval[[col]] <- as.vector(rep(fill,nrows), mode=newclass)
- }
-
## Handle case when current and previous native types differ
oldclass <- class(retval[[col]])
More information about the R-gregmisc-commits
mailing list