Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Silently drop NULLs in rbind.fill().

Closes #138
  • Loading branch information...
commit bd8cba31cc019c39e9eca24caece4dd05f250b0d 1 parent 3fe3221
Hadley Wickham authored
3  NEWS
View
@@ -1,5 +1,8 @@
Version 1.8.0.99
------------------------------------------------------------------------------
+
+* `rbind.fill` now silently drops NULL inputs (#138)
+
* `rbind.fill` avoids array copying which had produced quadratic time
complexity. `*dply` of large numbers of groups should be faster.
(Contributed by Peter Meilstrup)
3  R/rbind-fill.r
View
@@ -18,6 +18,8 @@
#'
#' @param ... input data frames to row bind together. The first argument can
#' be a list of data frames, in which case all other arguments are ignored.
+#' Any NULL inputs are silently dropped. If all inputs are NULL, the output
+#' is NULL.
#' @keywords manip
#' @family binding functions
#' @return a single data frame
@@ -30,6 +32,7 @@ rbind.fill <- function(...) {
if (is.list(dfs[[1]]) && !is.data.frame(dfs[[1]])) {
dfs <- dfs[[1]]
}
+ dfs <- compact(dfs)
if (length(dfs) == 0) return()
if (length(dfs) == 1) return(dfs[[1]])
7 inst/tests/test-rbind.r
View
@@ -292,3 +292,10 @@ test_that("rbind.fill performance linear with times", {
classes=c("time"))
expect_linear_enough(timings)
})
+
+test_that("NULLs silently dropped", {
+ expect_equal(rbind.fill(mtcars, NULL), mtcars)
+ expect_equal(rbind.fill(NULL, mtcars), mtcars)
+ expect_equal(rbind.fill(NULL, NULL), NULL)
+
+})
4 man/rbind.fill.Rd
View
@@ -7,7 +7,9 @@ rbind.fill(...)
\arguments{
\item{...}{input data frames to row bind together. The
first argument can be a list of data frames, in which
- case all other arguments are ignored.}
+ case all other arguments are ignored. Any NULL inputs
+ are silently dropped. If all inputs are NULL, the output
+ is NULL.}
}
\value{
a single data frame
Please sign in to comment.
Something went wrong with that request. Please try again.