[R-gregmisc-commits] r2064 - in pkg/gtools: R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sat Aug 8 03:44:09 CEST 2015
Author: warnes
Date: 2015-08-08 03:44:08 +0200 (Sat, 08 Aug 2015)
New Revision: 2064
Modified:
pkg/gtools/R/smartbind.R
pkg/gtools/man/smartbind.Rd
Log:
- smartbind() gets a new argument 'list' to pass a list of data
frames, instead of/in addition to data frames as arguments.
- Fix bug in smartbind's handling of factor levels.
Modified: pkg/gtools/R/smartbind.R
===================================================================
--- pkg/gtools/R/smartbind.R 2015-07-22 00:53:30 UTC (rev 2063)
+++ pkg/gtools/R/smartbind.R 2015-08-08 01:44:08 UTC (rev 2064)
@@ -2,9 +2,11 @@
## Function to do rbind of data frames quickly, even if the columns don't match
##
-smartbind <- function(..., fill=NA, sep=':', verbose=FALSE)
+smartbind <- function(..., list, fill=NA, sep=':', verbose=FALSE)
{
- data <- list(...)
+ data <-list(...)
+ if(!missing(list))
+ data <- modifyList(list, data)
if(is.null(names(data)))
names(data) <- as.character(1:length(data))
data <- lapply(data,
@@ -95,12 +97,12 @@
blockIndex <- blockIndex+1
}
- all.equal.or.null <- function(x,y,...)
+ all.equal.or.null <- function(x,y)
{
if(is.null(x) || is.null(y) )
return(TRUE)
else
- return(all.equal(x,y,...))
+ return(all.equal(x,y))
}
## Handle factors, merging levels
@@ -149,9 +151,9 @@
## and use that one
longestIndex <- which.max( sapply(colLevels, length) )
longestLevels <- colLevels[[longestIndex]]
- allSubset <- sapply(colLevels[-longestIndex],
+ allSubset <- all(sapply(colLevels[-longestIndex],
function(l) all(l %in% longestLevels)
- )
+ ))
if(allSubset)
{
if("ordered" %in% colClass)
Modified: pkg/gtools/man/smartbind.Rd
===================================================================
--- pkg/gtools/man/smartbind.Rd 2015-07-22 00:53:30 UTC (rev 2063)
+++ pkg/gtools/man/smartbind.Rd 2015-08-08 01:44:08 UTC (rev 2064)
@@ -5,10 +5,11 @@
Efficient rbind of data frames, even if the column names don't match
}
\usage{
-smartbind(..., fill=NA, sep=':', verbose=FALSE)
+smartbind(..., list, fill=NA, sep=':', verbose=FALSE)
}
\arguments{
\item{\dots}{Data frames to combine}
+ \item{list}{List containing data frames to combine}
\item{fill}{Value to use when 'filling' missing columns.
Defaults to \code{NA}. }
\item{sep}{Character string used to separate column names when pasting
More information about the R-gregmisc-commits
mailing list