I have a dataset as follows:
Pt EVENT
123 GGG
123 Nor
123 tre
144 GGG
1667 tre
1667 Nor
1667 tre
I am trying to prepare the data eventually for a Sankey diagram and in order to do this I need to get the data into the following shape
Pt
123 GGG Nor tre
144 GGG
1667 tre Nor tre
And then eventually I think into a source, target, value format as follows:
source target value
GGG Nor 1
GGG 1
tre tre 1
Nor tre 2
The part I don't understand is how to get from the original dataset to the second one. I thought I might be able to do it with dplyr but no joy:
Sankey<-EndoSubset %>%
group_by(Pt) %>%
select(t(EVENT))