I have a matrix that looks like the "main" data frame below:
date<-c("2014-01-01","2014-02-01","2014-01-01","2014-03-01")
value<-c(1,2,3,4)
group<-c("a","a","b","b")
main<-data.frame(date= date,value = value, group = group)
main
main looks like this. You can run the code and see.
date value group
1 2014-01-01 1 a
2 2014-02-01 2 a
3 2014-01-01 3 b
4 2014-03-01 4 b
Is there a way to make get all the groups from the group column and make them individual columns so my final data frame would look like this with 3 columns.
date a b
1 2014-01-01 1 3
2 2014-02-01 2
4 2014-03-01 4
I think what I am looking for is the OPPOSITE of the melt function. But I don't see an UNMELT function.
Thank you.