-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Labels
bugan unexpected problem or unintended behavioran unexpected problem or unintended behavioreach-row ↕️
Description
I don't think this is expected. I would have expected the first to return an x column containing c(1, 2, 3, 4) as a double vector.
library(dplyr)
df <- tibble(x = list(1, 2, 3, 4))
df <- rowwise(df)
# `x` isn't accessed an element at a time
mutate(df, y = x)
#> # A tibble: 4 × 2
#> # Rowwise:
#> x y
#> <list> <list>
#> 1 <dbl [1]> <dbl [1]>
#> 2 <dbl [1]> <dbl [1]>
#> 3 <dbl [1]> <dbl [1]>
#> 4 <dbl [1]> <dbl [1]>
# `x` is accessed an element at a time
mutate(df, y = x + 1)
#> # A tibble: 4 × 2
#> # Rowwise:
#> x y
#> <list> <dbl>
#> 1 <dbl [1]> 2
#> 2 <dbl [1]> 3
#> 3 <dbl [1]> 4
#> 4 <dbl [1]> 5I think something is off with this section. We can't just use the .data[[name]] result here, we need to unchop it (checking that all elements are size 1 first)
Lines 323 to 336 in 55dfc1c
| # column from the original data | |
| result <- .data[[name]] | |
| chunks <- mask$resolve(name) | |
| } | |
| if (inherits(.data, "rowwise_df") && vec_is_list(result)) { | |
| sizes <- list_sizes(result) | |
| wrong <- which(sizes != 1) | |
| if (length(wrong)) { | |
| # same error as would have been generated by mask$eval_all_mutate() | |
| group <- wrong[1L] | |
| mask$set_current_group(group) | |
| abort( |
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugan unexpected problem or unintended behavioran unexpected problem or unintended behavioreach-row ↕️