Is there a way to mutate a column that has been previously packed?
df <- tibble::tibble(x1 = 1:3, x2 = 4:6, x3 = 7:9, y = 1:3) |>
tidyr::pack(x = tidyselect::starts_with("x"))
For example, I'd like to modify x$x1 while preserving the overal structure of df. Something like this which obviously doesn't work:
dplyr::mutate(df, x$x1 = letters[1:3])
df$x <- dplyr::mutate(df$x, x1 = letters[1:3])
1 Like
Yeah actually I was just about to say I realised I had to use another mutate.
dplyr::mutate(df, x = dplyr::mutate(x, x1 = letters[1:3]))
system
Closed
4
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
If you have a query related to it or one of the replies, start a new topic and refer back with a link.