suppose I have the following dataframe:
df <- data.frame(Order=c("1234567","1234567","1234567","456789","456789"),Stage=c("Pipeline","Proposal","Closed","Pipeline","Lost"),StageChange=c("2008-01-01","2008-01-02","2008-01-03","2008-01-10","2008-01-12"))
Resulting in:
    head(df)
    Order    Stage StageChange
1 1234567 Pipeline  2008-01-01
2 1234567 Proposal  2008-01-02
3 1234567   Closed  2008-01-03
4  456789 Pipeline  2008-01-10
5  456789     Lost  2008-01-12
I need to unstack the "Stage" column and get to a dataframe like this:
    Order   Pipeline   Proposal     Closed       Lost
1 1234567 2008-01-01 2008-01-02 2008-01-03         NA
2  456789 2008-01-10         NA         NA 2008-01-12
I read the documentation and tried different approaches with dplyr and tidyr (like in this thread), but my ignorance is winning.
Any thoughts on to accomplish what I need?
My objective, to make it clear, is to use this data to calculate the number of days a particular Order spent on a specific Stage. Some orders are Lost, others are Closed (Won) and this is why there are "NA" values. Same happens when an order didn't change to a specific stage (an order can go from Pipeline to Lost, without any change to intermediary stages).
Thanks!