Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

data_rename() works with named vector #538

Merged
merged 2 commits into from
Sep 8, 2024

Conversation

strengejacke
Copy link
Member

No description provided.

@strengejacke strengejacke merged commit 0d30d24 into main Sep 8, 2024
21 of 22 checks passed
@strengejacke strengejacke deleted the data_rename-also-works-with-named-vector branch September 8, 2024 14:59
Comment on lines +17 to +20
expect_named(
data_rename(test, c(length = "Sepal.Length", width = "Sepal.Width")),
c("length", "width", "Petal.Length", "Petal.Width", "Species")
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, can you add a test about what happens when someone passes a partially named vector, e.g. data_rename(test, c(length = "Sepal.Length", "Sepal.Width"))? I suppose it would error but I just want to ensure it throws a nice error message.

Same thing for the case where the user passes a named vector and a replacement, e.g. data_rename(test, c(length = "Sepal.Length"), replacement = "Sepal.Width")

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First example will remove column name, second will ignore replacement. First example is in line with the current behaviour:
data_rename(iris, c("Sepal.Length", "Sepal.Width"), replacement = c("aaa", ""))

For the second case, I have made this more explicit in the docs.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #539

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants