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 that I want to use to reorder the dataset. The result should be a data frame that contains a row for each V3 value, as well as information about other variables in the same row.
In this example, I want something like this:
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 this? Thanks for your help!!!!