nealrichardson commented on a change in pull request #10724:
URL: https://github.com/apache/arrow/pull/10724#discussion_r671526253
##########
File path: r/R/dplyr-functions.R
##########
@@ -634,20 +655,45 @@ nse_funcs$wday <- function(x, label = FALSE, abbr = TRUE,
week_start = getOption
}
nse_funcs$log <- function(x, base = exp(1)) {
-
+
if (base == exp(1)) {
return(Expression$create("ln_checked", x))
}
-
+
if (base == 2) {
return(Expression$create("log2_checked", x))
}
-
+
if (base == 10) {
return(Expression$create("log10_checked", x))
- }
+ }
# ARROW-13345
stop("`base` values other than exp(1), 2 and 10 not supported in Arrow",
call. = FALSE)
}
nse_funcs$logb <- nse_funcs$log
+
+nse_funcs$if_else <- function(condition, true, false, missing = NULL){
+ if (!is.null(missing)) {
+ return(nse_funcs$if_else(
+ is.na(condition),
+ missing,
+ nse_funcs$if_else(condition, true, false)
+ ))
+ }
+
+ # if_else doesn't yet support factors/dictionaries
+ # TODO: remove this after ARROW-13358 is merged
+ warn_types <- nse_funcs$is.factor(true) | nse_funcs$is.factor(false)
+ if (warn_types) {
+ warning("Dictionaries (in R: factors) are currently converted to strings
(characters) in if_else and ifelse", call. = FALSE)
+ }
+
+ build_expr("if_else", condition, true, false)
+}
+
+# Although base R ifelse allows `yes` and `no` to be different classes
+#
+nse_funcs$ifelse <- function(test, yes, no){
+ nse_funcs$if_else(condition = test, true = yes, false = no)
Review comment:
```suggestion
nse_funcs$if_else(condition = test, true = yes, false = no)
```
--
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]