-
Notifications
You must be signed in to change notification settings - Fork 420
Closed
Milestone
Description
From tidyverse/tibble#766, CC @mvazquezs.
Is the previous behavior correct? Do we need a better error message?
tibble 2.1.3
library(tidyverse)
tibble(id = 1, x_1 = 1, x_2 = 2, y_1 = 1, y_2 = 2) %>%
pivot_longer(
cols = -id,
names_to = c("x", "x_dil"),
names_pattern = "(.+)_(.+)",
values_to = c("mfi", "dil")
)
#> # A tibble: 4 x 5
#> id x x_dil mfi dil
#> <dbl> <chr> <chr> <dbl> <dbl>
#> 1 1 x 1 1 NA
#> 2 1 x 2 NA 2
#> 3 1 y 1 1 NA
#> 4 1 y 2 NA 2Created on 2020-04-29 by the reprex package (v0.3.0)
tibble 3.0.1
library(tidyverse)
tibble(id = 1, x_1 = 1, x_2 = 2, y_1 = 1, y_2 = 2) %>%
pivot_longer(
cols = -id,
names_to = c("x", "x_dil"),
names_pattern = "(.+)_(.+)",
values_to = c("mfi", "dil")
)
#> Error: Assigned data `values_to` must be compatible with existing data.
#> x Existing data has 4 rows.
#> x Assigned data has 2 rows.
#> ℹ Only vectors of size 1 are recycled.Created on 2020-04-29 by the reprex package (v0.3.0)
Metadata
Metadata
Assignees
Labels
No labels