paleolimbot commented on pull request #11133:
URL: https://github.com/apache/arrow/pull/11133#issuecomment-919106956
With updated handling of `x`:
``` r
library(arrow, warn.conflicts = FALSE)
library(dplyr, warn.conflicts = FALSE)
# with base as a column
RecordBatch$create(a = 2:5, b = 2:5) %>%
mutate(log(a, base = b)) %>%
collect()
#> # A tibble: 4 × 3
#> a b `log(a, base = b)`
#> <int> <int> <dbl>
#> 1 2 2 1
#> 2 3 3 1
#> 3 4 4 1
#> 4 5 5 1
# with base as a scalar
RecordBatch$create(a = 2:5) %>%
mutate(log(a, base = 3)) %>%
collect()
#> # A tibble: 4 × 2
#> a `log(a, base = 3)`
#> <int> <dbl>
#> 1 2 0.631
#> 2 3 1
#> 3 4 1.26
#> 4 5 1.46
# with x as a scalar
RecordBatch$create(a = 2:5) %>%
mutate(log(2, base = a)) %>%
collect()
#> # A tibble: 4 × 2
#> a `log(2, base = a)`
#> <int> <dbl>
#> 1 2 1
#> 2 3 0.631
#> 3 4 0.5
#> 4 5 0.431
# errors for base with length != 1
RecordBatch$create(a = 2:5) %>%
mutate(log(a, base = 3:4)) %>%
collect()
#> Warning: In log(a, base = 3:4), base must be a column or a length-1
numeric;
#> other values not supported by Arrow; pulling data into R
#> # A tibble: 4 × 2
#> a `log(a, base = 3:4)`
#> <int> <dbl>
#> 1 2 0.631
#> 2 3 0.792
#> 3 4 1.26
#> 4 5 1.16
# errors for x with length != 1
RecordBatch$create(a = 2:5) %>%
mutate(log(a, base = 3:4)) %>%
collect()
#> Warning: In log(a, base = 3:4), base must be a column or a length-1
numeric;
#> other values not supported by Arrow; pulling data into R
#> # A tibble: 4 × 2
#> a `log(a, base = 3:4)`
#> <int> <dbl>
#> 1 2 0.631
#> 2 3 0.792
#> 3 4 1.26
#> 4 5 1.16
```
<sup>Created on 2021-09-14 by the [reprex
package](https://reprex.tidyverse.org) (v2.0.1)</sup>
--
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]