I created the following data frame in R:
V1 <- c(1,3,2,6,7,7,5,3,1,1)
V2 <- c("rot", "grün", "grün", "gelb", "blau", "rot", "grün", "blau",
"blau", "schwarz")
V3 <- c(44,23,28,23,88,88,44,28,11,44)
as.data.frame(cbind(V1,V2,V3) )
V1 V2 V3
1 1 rot 44
2 3 grün 23
3 2 grün 28
4 6 gelb 23
5 7 blau 88
6 7 rot 88
7 5 grün 44
8 3 blau 28
9 1 blau 11
10 1 schwarz 44
V3 is the variable I want to use to rearrange the data set. The result should be a data frame that contains a row for each value of V3, and the information on the other variables in the same row.
For this example, what I want is something like that:
V3 V1.1 V2.1 V2.1 V2.2 V1.3 V2.3
11 1 blau NA NA NA NA
23 3 grün 6 gelb NA NA
28 2 grün 3 blau NA NA
44 1 rot 5 grün 1 schwarz
88 7 blau 7 rot NA NA
Is there a function that can do that? Thanks for your help!!!!