From d108553e0db45ce1c8f88510af3807e545c948bc Mon Sep 17 00:00:00 2001 From: Teun van den Brand <49372158+teunbrand@users.noreply.github.com> Date: Mon, 25 Sep 2023 09:28:19 +0200 Subject: [PATCH] Omit rownames from check --- R/aes.R | 2 +- tests/testthat/test-aes.R | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/R/aes.R b/R/aes.R index 62a329e120..fc545c4198 100644 --- a/R/aes.R +++ b/R/aes.R @@ -436,7 +436,7 @@ extract_target_is_likely_data <- function(x, data, env) { tryCatch({ data_eval <- eval_tidy(x[[2]], data, env) - identical(data_eval, data) + identical(unrowname(data_eval), unrowname(data)) }, error = function(err) FALSE) } diff --git a/tests/testthat/test-aes.R b/tests/testthat/test-aes.R index 3ac67b9c47..92b51b94e8 100644 --- a/tests/testthat/test-aes.R +++ b/tests/testthat/test-aes.R @@ -128,6 +128,14 @@ test_that("warn_for_aes_extract_usage() warns for discouraged uses of $ and [[ w warn_for_aes_extract_usage(aes(df[["x"]]), df), 'Use of `df\\[\\["x"\\]\\]` is discouraged' ) + + # Check that rownames are ignored (#5392) + df2 <- df + rownames(df2) <- LETTERS[seq_len(nrow(df))] + expect_warning( + warn_for_aes_extract_usage(aes(df$x), df2), + "Use of `df\\$x` is discouraged" + ) }) test_that("warn_for_aes_extract_usage() does not evaluate function calls", {