I have a data frame that is not really in a 'long form' but it is in a longer form than I would like. I would like to condense it into a 'wide form' that has all the information associated with an id into one line. Right now, some of the information is repeated on each line (like the date in the example below) and other information needs to be preserved when the lines are consolidated (like type column below). thanks!
id <- c(1000, 1000, 1000, 1001, 1001, 1001)
type <- c("A", "B", "B", "C", "C", "A")
dates <- c("10/5/2019", "10/5/2019", "10/5/2019", "9/17/2020", "9/17/2020", "9/17/2020")
df <- as.data.frame(cbind(id, type, dates))
df
id type dates
1 1000 A 10/5/2019
2 1000 B 10/5/2019
3 1000 B 10/5/2019
4 1001 C 9/17/2020
5 1001 C 9/17/2020
6 1001 A 9/17/2020
I would like it to looks like this: