Skip to content

Commit 3f46e31

Browse files
authored
set trust = TRUE also for RData files (#557)
* set `trust = TRUE` also for RData files * fix test * lintr
1 parent 213b9d5 commit 3f46e31

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Type: Package
22
Package: datawizard
33
Title: Easy Data Wrangling and Statistical Transformations
4-
Version: 0.13.0.7
4+
Version: 0.13.0.8
55
Authors@R: c(
66
person("Indrajeet", "Patil", , "[email protected]", role = "aut",
77
comment = c(ORCID = "0000-0003-1995-6531")),

NEWS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ CHANGES
1616

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

19+
* `data_read()` no longer shows warning about forthcoming breaking changes
20+
in upstream packages when reading `.RData` files.
21+
1922
BUG FIXES
2023

2124
* `describe_distribution()` no longer errors if the sample was too sparse to compute

R/data_read.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ data_read <- function(path,
161161
# user may decide whether we automatically detect variable type or not
162162
if (isTRUE(convert_factors)) {
163163
if (verbose) {
164-
msg <- "Variables where all values have associated labels are now converted into factors. If this is not intended, use `convert_factors = FALSE`."
164+
msg <- "Variables where all values have associated labels are now converted into factors. If this is not intended, use `convert_factors = FALSE`." # nolint
165165
insight::format_alert(msg)
166166
}
167167
x[] <- lapply(x, function(i) {
@@ -296,7 +296,7 @@ data_read <- function(path,
296296
# set up arguments. for RDS, we set trust = TRUE, to avoid warnings
297297
rio_args <- list(file = path)
298298
# check if we have RDS, and if so, add trust = TRUE
299-
if (file_type == "rds") {
299+
if (file_type %in% c("rds", "rdata")) {
300300
rio_args$trust <- TRUE
301301
}
302302
out <- do.call(rio::import, c(rio_args, list(...)))

tests/testthat/test-data_read.R

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,19 @@ test_that("data_read - RDS file, matrix, coercible", {
154154
})
155155

156156

157+
158+
# RData -----------------------------------
159+
160+
test_that("data_read - no warning for RData", {
161+
withr::with_tempfile("temp_file", fileext = ".RData", code = {
162+
data(mtcars)
163+
save(mtcars, file = temp_file)
164+
expect_silent(data_read(temp_file, verbose = FALSE))
165+
})
166+
})
167+
168+
169+
157170
# SPSS file -----------------------------------
158171

159172
test_that("data_read - SPSS file", {

0 commit comments

Comments
 (0)