Dragoș Moldovan-Grünfeld created ARROW-14362:
------------------------------------------------
Summary: [R] Should case_when() work outside mutate()
Key: ARROW-14362
URL: https://issues.apache.org/jira/browse/ARROW-14362
Project: Apache Arrow
Issue Type: Improvement
Components: R
Reporter: Dragoș Moldovan-Grünfeld
Currently {{arrow::case_when()}} has been implemented to work inside an
{{arrow::mutate()}} call. As a consequence, this chunk of code errors:
{code:r}
arrow_vec <- Array$create(c(1:3, 5:8))
case_when(arrow_vec < 4 ~ "less than 4", TRUE ~ "greater than 4")
Error: LHS of case 1 (`arrow_vec < 4`) must be a logical vector, not a
`Array/ArrowDatum/ArrowObject/R6` object.
{code}
while the equivalent dplyr code works:
{code:r}
library(dplyr)
num_vec <- c(1:3, 5:8)
case_when(
num_vec < 4 ~ "less than 4",
TRUE ~ "greater than 4")
[1] "less than 4" "less than 4" "less than 4" "greater than 4"
[5] "greater than 4" "greater than 4" "greater than 4"
{code}
This is related to
[ARROW-13799|https://issues.apache.org/jira/browse/ARROW-13799].
--
This message was sent by Atlassian Jira
(v8.3.4#803005)