I have data that looks like this:
ID X1 X2 X3
1 1.4 2 two
2 7.6 30 thirty
2 7.6 50 fifty
2 7.6 40 forty
3 5.6 40 forty
3 5.6 50 fifty
4 3.5 NA NA
5 NA 2 two
The identifier indicates individuals, X1 is a measurement taken once for each person, and X2 and X3 are symbolic and string representations of the same treatment. For example, for individual 2, X1 = 7.6 and processed X2 = 30, 50, and 40 (which is related to other information, X3 = thirty, fifty, and forty)
I want it to look like this: only one row per individual user and values ββfrom several observations of the same person added to new columns:
ID X1 X2a X3a X2b X3b X2c X3c
1 1.4 2 two NA NA NA NA
2 7.6 30 thirty 50 fifty 40 forty
3 5.6 40 forty 50 fifty NA NA
4 3.5 NA NA NA NA NA NA
5 NA 2 two NA NA NA NA
X1 = NA (, 5), , .
(10 000 , , 50 ), , , .
melt() cast() reshape, , , , . , (: fun.aggregate: length ), . , ? ?
(, ), , , , , ...