Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Type: Package
Title: recombinator (http://github.com/robertzk/recombinator)
Description: R tools for turning nested lists into data.frames
in an orderly manner.
Version: 0.1.0
Version: 0.1.1
Author: Robert Krzyzanowski <technoguyrob@gmail.com>
Maintainer: Robert Krzyzanowski <technoguyrob@gmail.com>
Authors@R: c(person("Robert", "Krzyzanowski",
Expand Down
6 changes: 5 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Version 0.1.1

* Recombinator now returns non-list data idempotently. Resolves #3.

# Version 0.1.0

* The initial creation of the package.
* The initial creation of the package.
2 changes: 1 addition & 1 deletion R/recombinator.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#' those containing more than alphanumeric, underscore, and period
#' characters) are used.
recombinator <- function(dat, id = "id") {
if (!is.list(dat)) data
if (!is.list(dat) || is.data.frame(dat)) dat
else if (is.character(dat[[1L]])) {
homogeneous_recombinator(dat, id)
} else if (is.list(dat[[1L]]) && all(nzchar(names(dat[[1L]])))) {
Expand Down
7 changes: 7 additions & 0 deletions tests/testthat/test-recombinators.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ test_that("homogeneous recombinator can parse a simple example correctly", {
expect_identical(homogeneous_recombinator(pre_dataframe), df)
})

test_that("recombinator returns the input for non-list input. Issue #3", {
expect_identical("pizza", recombinator("pizza"))
expect_identical(123, recombinator(123))
expect_identical(TRUE, recombinator(TRUE))
expect_identical(data.frame(a = 1, b = 2), recombinator(data.frame(a = 1, b = 2)))
})

test_that("recombinator calls to heterogeneous recombinator correctly", {
pre_dataframe <-
list(list(variable_one = 1, variable_two = "a"),
Expand Down