thisisnic commented on a change in pull request #12642:
URL: https://github.com/apache/arrow/pull/12642#discussion_r832246876
##########
File path: r/R/dplyr-select.R
##########
@@ -32,6 +32,16 @@ rename.arrow_dplyr_query <- function(.data, ...) {
}
rename.Dataset <- rename.ArrowTabular <- rename.RecordBatchReader <-
rename.arrow_dplyr_query
+rename_with.arrow_dplyr_query <- function(.data, .fn, .cols = everything(),
...) {
+ .fn <- rlang::as_function(.fn)
+ old_names <- names(select(.data, {{ .cols }}))
+ new_names <- do.call(.fn, list(old_names))
+ rename_args <- c(list(.data), as.list(old_names))
+ names(rename_args) <- c(".data", new_names)
+ do.call(rename, rename_args)
Review comment:
```suggestion
rename(.data, !!set_names(old_names, new_names))
```
Minor change here to make this more `rlang` style in keeping with the other
code in the package + avoiding use of `do.call`.
##########
File path: r/R/dplyr-select.R
##########
@@ -32,6 +32,16 @@ rename.arrow_dplyr_query <- function(.data, ...) {
}
rename.Dataset <- rename.ArrowTabular <- rename.RecordBatchReader <-
rename.arrow_dplyr_query
+rename_with.arrow_dplyr_query <- function(.data, .fn, .cols = everything(),
...) {
+ .fn <- rlang::as_function(.fn)
+ old_names <- names(select(.data, {{ .cols }}))
+ new_names <- do.call(.fn, list(old_names))
+ rename_args <- c(list(.data), as.list(old_names))
+ names(rename_args) <- c(".data", new_names)
+ do.call(rename, rename_args)
Review comment:
```suggestion
rename(.data, !!set_names(old_names, new_names))
```
Minor change here to make this more `rlang` style in keeping with the other
code in the package + avoiding use of `do.call()`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]