How to create relational matrix in R?
问题 Original data: df <- structure(list(ID_client = structure(c(1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L), .Label = c("1_", "2_", "3_", "4_"), class = "factor"), Connected = c(1L, 1L, 1L, 0L, 1L, 0L, 1L, 0L), Year = c(2010L, 2010L, 2010L, 2010L, 2015L, 2015L, 2015L, 2015L)), class = "data.frame", row.names = c(NA, -8L)) Original data: `ID_client Connected Year 1_ 1 2010 2_ 1 2010 3_ 1 2010 4_ 0 2010 1_ 1 2015 2_ 0 2015 3_ 1 2015 4_ 0 2015` My intention is to create the following data: `Year ID_client 1_ 2_