Skip to content

Commit

Permalink
set trust = TRUE also for RData files (#557)
Browse files Browse the repository at this point in the history
* set `trust = TRUE` also for RData files

* fix test

* lintr
  • Loading branch information
strengejacke authored Oct 12, 2024
1 parent 213b9d5 commit 3f46e31
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: datawizard
Title: Easy Data Wrangling and Statistical Transformations
Version: 0.13.0.7
Version: 0.13.0.8
Authors@R: c(
person("Indrajeet", "Patil", , "[email protected]", role = "aut",
comment = c(ORCID = "0000-0003-1995-6531")),
Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ CHANGES

* New function `row_count()`, to count specific values row-wise.

* `data_read()` no longer shows warning about forthcoming breaking changes
in upstream packages when reading `.RData` files.

BUG FIXES

* `describe_distribution()` no longer errors if the sample was too sparse to compute
Expand Down
4 changes: 2 additions & 2 deletions R/data_read.R
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ data_read <- function(path,
# user may decide whether we automatically detect variable type or not
if (isTRUE(convert_factors)) {
if (verbose) {
msg <- "Variables where all values have associated labels are now converted into factors. If this is not intended, use `convert_factors = FALSE`."
msg <- "Variables where all values have associated labels are now converted into factors. If this is not intended, use `convert_factors = FALSE`." # nolint
insight::format_alert(msg)
}
x[] <- lapply(x, function(i) {
Expand Down Expand Up @@ -296,7 +296,7 @@ data_read <- function(path,
# set up arguments. for RDS, we set trust = TRUE, to avoid warnings
rio_args <- list(file = path)
# check if we have RDS, and if so, add trust = TRUE
if (file_type == "rds") {
if (file_type %in% c("rds", "rdata")) {
rio_args$trust <- TRUE
}
out <- do.call(rio::import, c(rio_args, list(...)))
Expand Down
13 changes: 13 additions & 0 deletions tests/testthat/test-data_read.R
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,19 @@ test_that("data_read - RDS file, matrix, coercible", {
})



# RData -----------------------------------

test_that("data_read - no warning for RData", {
withr::with_tempfile("temp_file", fileext = ".RData", code = {
data(mtcars)
save(mtcars, file = temp_file)
expect_silent(data_read(temp_file, verbose = FALSE))
})
})



# SPSS file -----------------------------------

test_that("data_read - SPSS file", {
Expand Down

0 comments on commit 3f46e31

Please sign in to comment.