Skip to content

Commit c77e9ff

Browse files
Merge branch 'main' into rc_datawizard_1.2.0
2 parents ed28947 + 5632d4d commit c77e9ff

File tree

6 files changed

+12
-86
lines changed

6 files changed

+12
-86
lines changed

NEWS.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# datawizard 1.2.0
22

3+
BREAKING CHANGES
4+
5+
* The following deprecated arguments have been removed (#603):
6+
- `drop_na` in `data_match()`
7+
- `safe`, `pattern`, and `verbose` in `data_rename()`
8+
39
CHANGES
410

511
* `data_read()` and `data_write()` now support the `.parquet` file format, via
@@ -58,7 +64,7 @@ CHANGES
5864

5965
* `data_codebook()` gives an informative warning when no column names matched
6066
the selection pattern (#601).
61-
67+
6268
* `data_to_long()` now errors when columns selected to reshape do not exist in
6369
the data, to avoid nonsensical results that could be missed (#602).
6470

R/data_match.R

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#' character vector (e.g. `c("x > 4", "y == 2")`) or a variable that contains
2727
#' the string representation of a logical expression. These might be useful
2828
#' when used in packages to avoid defining undefined global variables.
29-
#' @param drop_na Deprecated, please use `remove_na` instead.
3029
#'
3130
#' @return A filtered data frame, or the row indices that match the specified
3231
#' configuration.
@@ -106,19 +105,12 @@ data_match <- function(x,
106105
match = "and",
107106
return_indices = FALSE,
108107
remove_na = TRUE,
109-
drop_na,
110108
...) {
111109
if (!is.data.frame(to)) {
112110
to <- as.data.frame(to)
113111
}
114112
original_x <- x
115113

116-
## TODO: remove deprecated argument later
117-
if (!missing(drop_na)) {
118-
insight::format_warning("Argument `drop_na` is deprecated. Please use `remove_na` instead.")
119-
remove_na <- drop_na
120-
}
121-
122114
# evaluate
123115
match <- match.arg(tolower(match), c("and", "&", "&&", "or", "|", "||", "!", "not"))
124116
match <- switch(match,

R/data_rename.R

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@
4040
#'
4141
#' If `select` is a named vector, `replacement` is ignored.
4242
#' @param rows Vector of row names.
43-
#' @param safe Deprecated. Passing unknown column names now always errors.
44-
#' @param pattern Deprecated. Use `select` instead.
4543
#' @param ... Other arguments passed to or from other functions.
4644
#'
4745
#' @details
@@ -87,27 +85,11 @@
8785
data_rename <- function(data,
8886
select = NULL,
8987
replacement = NULL,
90-
safe = TRUE,
91-
verbose = TRUE,
92-
pattern = NULL,
9388
...) {
9489
# check for valid input
9590
if (!is.data.frame(data)) {
9691
insight::format_error("Argument `data` must be a data frame.")
9792
}
98-
# If the user does data_rename(iris, pattern = "Sepal.Length", "length"),
99-
# then "length" is matched to select by position while it's the replacement
100-
# => do the switch manually
101-
if (!is.null(pattern)) {
102-
.is_deprecated("pattern", "select")
103-
if (!is.null(select)) {
104-
replacement <- select
105-
}
106-
select <- pattern
107-
}
108-
if (isFALSE(safe)) {
109-
insight::format_warning("In `data_rename()`, argument `safe` is no longer used and will be removed in a future release.") # nolint
110-
}
11193

11294
# change all names if no pattern specified
11395
select <- .select_nse(
@@ -117,7 +99,6 @@ data_rename <- function(data,
11799
ignore_case = NULL,
118100
regex = NULL,
119101
allow_rename = TRUE,
120-
verbose = verbose,
121102
ifnotfound = "error"
122103
)
123104

@@ -189,25 +170,17 @@ data_rename <- function(data,
189170

190171
for (i in seq_along(select)) {
191172
if (!is.na(replacement[i])) {
192-
data <- .data_rename(data, select[i], replacement[i], safe, verbose)
173+
data <- .data_rename(data, select[i], replacement[i])
193174
}
194175
}
195176

196177
data
197178
}
198179

199180
#' @keywords internal
200-
.data_rename <- function(data, pattern, replacement, safe = TRUE, verbose = TRUE) {
181+
.data_rename <- function(data, pattern, replacement) {
201182
if (!pattern %in% names(data)) {
202-
if (isTRUE(safe)) {
203-
# only give message when verbose is TRUE
204-
if (verbose) {
205-
insight::format_alert(paste0("Variable `", pattern, "` is not in your data frame :/"))
206-
}
207-
# if not safe, always error, no matter what verbose is
208-
} else {
209-
insight::format_error(paste0("Variable `", pattern, "` is not in your data frame :/"))
210-
}
183+
insight::format_error(paste0("Variable `", pattern, "` is not in your data frame :/"))
211184
}
212185

213186
names(data) <- replace(names(data), names(data) == pattern, replacement)

man/data_match.Rd

Lines changed: 1 addition & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/data_rename.Rd

Lines changed: 1 addition & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-data_rename.R

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -90,19 +90,6 @@ test_that("data_rename errors when select = NULL", {
9090

9191
# other --------------
9292

93-
test_that("data_rename: argument 'safe' is deprecated", {
94-
expect_error(
95-
data_rename(iris, "FakeCol", "length", verbose = FALSE),
96-
"were not found"
97-
)
98-
expect_error(
99-
expect_warning(
100-
data_rename(iris, "FakeCol", "length", safe = FALSE, verbose = FALSE),
101-
"used"
102-
)
103-
)
104-
})
105-
10693
test_that("data_rename deals correctly with duplicated replacement", {
10794
x <- data_rename(test,
10895
select = names(test)[1:4],
@@ -214,14 +201,6 @@ withr::with_environment(
214201
})
215202
)
216203

217-
test_that("Argument `pattern` is deprecated", {
218-
expect_warning(
219-
head(data_rename(iris, pattern = "Sepal.Length", "length")),
220-
"Argument `pattern` is deprecated. Please use `select` instead.",
221-
fixed = TRUE
222-
)
223-
})
224-
225204
test_that("works with lists", {
226205
result <- list(x = 1, y = 2)
227206
expect_error(

0 commit comments

Comments
 (0)