Skip to content

Commit

Permalink
issue #771: data.table data in datasummary_correlation
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentarelbundock committed Jun 14, 2024
1 parent 53a0ba7 commit ba7a688
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Description: Create beautiful and customizable tables to summarize several
RTF, JPG, or PNG. Tables can easily be embedded in 'Rmarkdown' or 'knitr'
dynamic documents. Details can be found in Arel-Bundock (2022)
<doi:10.18637/jss.v103.i01>.
Version: 2.1.0.5
Version: 2.1.0.6
Authors@R: c(person("Vincent", "Arel-Bundock",
email = "[email protected]",
role = c("aut", "cre"),
Expand Down
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

Bugs:

* `escape` was not respected in `datasummary_correlation()`. Issue #772.
* `datasummary_correlation()` respects the `escape` argument. Issue #772.
* `datasummary_correlation()` supports `data.table` objects. Issue #771.


## 2.1.0
Expand Down
4 changes: 4 additions & 0 deletions R/datasummary_correlation.R
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ datasummary_correlation <- function(data,
sanitize_escape(escape) # after sanitize_output
sanity_add_columns(add_columns)
sanity_align(align)

if (inherits(data, "data.table")) {
data <- as.data.frame(data, check.names = FALSE)
}

easycorrelation <- inherits(data, "easycorrelation")

Expand Down
6 changes: 6 additions & 0 deletions inst/tinytest/test-datasummary_correlation.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
source("helpers.R")
requiet("tinysnapshot")
requiet("data.table")
using("tinysnapshot")
if (!requiet("correlation")) exit_file("correlation package")

Expand Down Expand Up @@ -32,3 +33,8 @@ expect_false(grepl("foo_bar", escape_true))
expect_true(grepl("foo_bar", escape_false))
expect_true(grepl("foo\\\\_bar", escape_true))

# issue #771: data.table support
x <- setNames(iris[, 1:3], c("blah blah", "hello world", "foo bar"))
x <- data.table(x)
x <- datasummary_correlation(x)
expect_inherits(x, "tinytable")

0 comments on commit ba7a688

Please sign in to comment.