I've searched quite some time for this and can't figure out a way that doesn't seem to send me down what appears to be the wrong path. I'm trying to replicate the following SAS implementation within R.
Right now I’m trying to figure out how to transpose, without aggregation, several values based on several identifying fields.
Example starting point:
Cat1 Cat2 Cat3 Date Occ Dur
A00 Group1 Sub1 2015-05-09 1 30
A00 Group1 Sub1 2015-09-09 2 30
A00 Group1 Sub2 2015-06-23 1 60
B00 Group1 Sub1 2015-07-30 3 30
B00 Group1 Sub2 2015-03-25 1 60
B00 Group1 Sub2 2015-02-14 2 60
And i'm looking to get the following output:
Cat1 Cat2 Cat3 Date1 Date2 Occ1 Occ2 Dur1 Dur2
A00 Group1 Sub1 2015-05-09 2015-09-09 1 2 30 30
A00 Group1 Sub2 2015-06-23 1 60
B00 Group1 Sub1 2015-07-30 3 30
B00 Group1 Sub2 2015-03-25 2015-02-14 1 2 60 60
I realize that different environments may require different approaches. I'm certainly open for alternative solutions than directly trying to replicate the logic within SAS. I've tried various attempts at reshaping the data with melt and cast without any luck. Any assistance would be hugely appreciated!