I currently have long format data
# Input
library(dplyr)
library(tidyr)
tibble(
x = c(1,1,2,2),
y = c("A", "B", "C", "D")
)
I want to widen the data to look like this:
# Desired Output
tibble(
x = c(1,2),
x_1 = c("A", "C"),
x_2 = c("B", "D")
)
But this isn't a typical tidyr::spread()
because my column names are not becoming cell values. So while this seems simple, I'm stumped.