I am trying to spread the "value" column in my data below so that I have different columns for Brand1 and Brand2 with their values underneath as seen in the data. However, I am not able to apply spread or pivot_wider correctly here for some reason.
df2 <- data.frame(
stringsAsFactors = FALSE,
date = c(NA,"1996-01-01",
"1996-02-01",NA,"1996-01-01","1996-02-01"),
class = c("Class 1",
"Class 1","Class 1","Class 1","Class 1","Class 1"),
value = c("Brand1", "376", "393", "Brand2", "928", "932")
)
Any help with how you would solve this would be appreciated.