I would like to know the best method to summarise my data and create new columns that are named using the values in an existing column.
My current data frame looks like this:
observation=c(1,1,1,2,2,2,3,3,3)
event=c('event1','event2','event3','event1','event2','event3','event1','event2','event3')
value=c(1,2,3,4,5,6,7,8,9)
current=data.frame(observation,event,value)
current
I would like my new data frame to look like this:
observation=c(1,2,3)
event1_value =c(1,4,7)
event2_value =c(2,5,8)
event3_value =c(3,6,9)
required=data.frame(observation,event1_value,event2_value,event3_value)
required
I've tried to use the transpose function and the sqldf package to group the data by the observation column however I can't get the format I require.