ianmcook commented on a change in pull request #11023:
URL: https://github.com/apache/arrow/pull/11023#discussion_r741575436
##########
File path: r/R/expression.R
##########
@@ -100,7 +100,8 @@
# use `%/%` above.
"%%" = "divide_checked",
"^" = "power_checked",
- "%in%" = "is_in_meta_binary"
+ "%in%" = "is_in_meta_binary",
+ "strrep" = "binary_repeat"
Review comment:
`strrep()` is a function in base R. There is also a function
[`str_dup()`](https://stringr.tidyverse.org/reference/str_dup.html) in the
popular R package **stringr** that does exactly the same thing. In the R
bindings we often like to add these **stringr** variants of the functions too:
```suggestion
"strrep" = "binary_repeat",
"str_dup" = "binary_repeat"
```
##########
File path: r/tests/testthat/test-dplyr-funcs-string.R
##########
@@ -467,6 +467,18 @@ test_that("strsplit and str_split", {
)
})
+test_that("strrep", {
+ df <- tibble(x = c("foo1", " \tB a R\n", "!apACHe aRroW!"))
+ for (times in 0:8L) {
+ compare_dplyr_binding(
+ .input %>%
+ mutate(x = strrep(x, times)) %>%
+ collect(),
+ df
+ )
+ }
+})
+
Review comment:
Adds a test for the `str_dup()` binding I suggested above. Also FYI you
don't need the `L` after `8` because the `:` operator in R always creates
integer vectors when its operands are whole numbers.
```suggestion
test_that("strrep, str_dup", {
df <- tibble(x = c("foo1", " \tB a R\n", "!apACHe aRroW!"))
for (times in 0:8) {
compare_dplyr_binding(
.input %>%
mutate(x = strrep(x, times)) %>%
collect(),
df
)
compare_dplyr_binding(
.input %>%
mutate(x = str_dup(x, times)) %>%
collect(),
df
)
}
})
```
--
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]