-2
ich folgende Datenrahmen df habenUmsetzung Reihen in mehrere Spalten in R
ID Year Var value
1 2011 x1 1.2
1 2011 x2 2
1 2012 x1 1.5
1 2012 x2 2.3
3 2013 x1 3
3 2014 x1 4
4 2015 x1 5
5 2016 x1 6
4 2016 x1 2
Ich möchte
die Daten in folgendem Format zu transformierenID Year x1 x2
1 2011 1.2 2
1 2011 2 NA
1 2012 1.5 2.3
3 2013 3 NA
3 2014 4 4
4 2015 5 NA
4 2016 2 NA
5 2016 6 NA
helfen Bitte
Mögliches Duplikat von [Wie umformatieren Sie Daten vom Long- in das Wide-Format?] (Https://stackoverflow.com/questions/5890584/how-to-reshape-data-from-long-to-wide-format) – Uwe