Is it possible to use rows_update with non-unique x values?
library(dplyr)
x = tibble(x = c(1,1,2), z = "x")
y = tibble(x = c(1,2), z = "y")
rows_update(x, y)
#> Matching, by = "x"
#> Error: `x` key values are not unique.
Created on 2020-07-17 by the reprex package (v0.3.0)
The issue is that rows_update requires key variables to take unique values. If the constraint is to use rows_update without creating extra-columns, I would propose:
x %>% distinct() %>%
rows_update(y, by = "x") %>%
right_join(x %>% select(x), by = "x")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With