Mutating a packed column

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]))