[R-gregmisc-commits] r2066 - pkg/gtools/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sat Aug 8 05:14:15 CEST 2015
Author: warnes
Date: 2015-08-08 05:14:02 +0200 (Sat, 08 Aug 2015)
New Revision: 2066
Modified:
pkg/gtools/R/smartbind.R
Log:
- Improve assignment of default names in smartbind.
- Disambiguate 'list' into an object named 'list' and the function
base::list() in smartbind().
Modified: pkg/gtools/R/smartbind.R
===================================================================
--- pkg/gtools/R/smartbind.R 2015-08-08 01:47:43 UTC (rev 2065)
+++ pkg/gtools/R/smartbind.R 2015-08-08 03:14:02 UTC (rev 2066)
@@ -4,11 +4,21 @@
smartbind <- function(..., list, fill=NA, sep=':', verbose=FALSE)
{
- data <-list(...)
+ data <- base::list(...)
if(!missing(list))
- data <- modifyList(list, data)
+ {
+ data <- modifyList(list, data)
+ }
+
+ defaultNames <- seq.int(length(data))
+
if(is.null(names(data)))
- names(data) <- as.character(1:length(data))
+ names(data) <- defaultNames
+
+ emptyNames <- names(data)==""
+ if (any(emptyNames) )
+ names(data)[emptyNames] <- defaultNames[emptyNames]
+
data <- lapply(data,
function(x)
if(is.matrix(x) || is.data.frame(x))
@@ -18,7 +28,7 @@
)
#retval <- new.env()
- retval <- list()
+ retval <- base::list()
rowLens <- unlist(lapply(data, nrow))
nrows <- sum(rowLens)
@@ -37,9 +47,9 @@
blockIndex <- 1
for(block in data)
{
- colClassList [[blockIndex]] <- list()
+ colClassList [[blockIndex]] <- base::list()
factorColumnList[[blockIndex]] <- character(length=0)
- factorLevelList [[blockIndex]] <- list()
+ factorLevelList [[blockIndex]] <- base::list()
if(verbose) print(head(block))
end <- start+nrow(block)-1
More information about the R-gregmisc-commits
mailing list