Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Nov 27, 2024
1 parent d6a5456 commit 3d64e69
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
12 changes: 5 additions & 7 deletions R/data_rename.R
Original file line number Diff line number Diff line change
Expand Up @@ -266,13 +266,11 @@ data_rename <- function(data,
# if so, iterate all tokens
for (token in matches) {
# evaluate token-object from the environment
values <- tryCatch(
.dynEval(str2lang(gsub("\\{(.*)\\}", "\\1", token))),
error = function(e) {
insight::format_error(paste0(
"The object `", token, "` was not found. Please check if it really exists."
))
}
values <- .dynEval(
str2lang(gsub("\\{(.*)\\}", "\\1", token)),
ifnotfound = insight::format_error(paste0(
"The object `", token, "` was not found. Please check if it really exists."
))
)
# check for correct length
if (length(values) != length(pattern)) {
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-data_rename.R
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ test_that("data_rename enough letters", {
mtcars[1:5, ], iris[1:5, ], efc[1:5, ], ChickWeight[1:5, ], ToothGrowth[1:5, ],
USArrests[1:5, ], airquality[1:5, ]
)
expect_names(
expect_named(
data_rename(x, replacement = "long_letter_{letter}"),
c(
"long_letter_a1", "long_letter_b1", "long_letter_c1", "long_letter_d1",
Expand Down

0 comments on commit 3d64e69

Please sign in to comment.