I would like to reshape the following data frame dat:
dat<-data.frame( ID=c(100,101,101,101,102,103), DEGREE=c("BA","BA","MS","PHD","BA","BA"), YEAR=c(1980,1990, 1992, 1996, 2000, 2004)
Where ID is an ID number tied to an individual, DEGREE is the type of DEGREE EARNED, and YEAR is the year in which the degree was earned. In this case, ID 101 earned a BA, MS, and PHD.
I would like to reshape the data into a wide format such that there are columns for each degree, but are not named after the degree value themselves. Additionally, I would like the years corresponding to each degree.
Like such :
The main point being that I do not want to create new columns based on the values of DEGREE or YEAR (this is what happens when I attempted to use spread, dcast, etc).
Thank you!