I have 4 dummy variables taking values 0 or 1 corresponding to the adoption or not of a certain technology. The data frame has over 14000 rows.
I want to loop over these 4 columns to give me the different combinations of == 1 into a new variable.
Data
structure(list(tech1 = structure(c(2L, 1L, 1L, 1L), .Label = c("0", "1"), class = "factor"), tech2 = structure(c(2L, 2L, 2L, 2L), .Label = c("0", "1"), class = "factor"), tech3 = structure(c(1L, 1L, 2L, 1L), .Label = c("0", "1"), class = "factor"), tech4 = structure(c(1L, 1L, 2L, 1L), .Label = c("0", "1"), class = "factor")), row.names = c(NA, 4L), class = "data.frame")
As different combinations are possible, my new variable should contain the information of which technologies each row indicates, that is, of the 4 technologies, which ones were adopted in each case.
Here is how the four first rows of the new variable could look like at the end (supposing "12" = adopted technologies 1 and 2 and so on):
Variable "Tech":
structure(list(Tech = structure(c(1L, 2L, 3L, 4L), .Label = c("12", "2", "234", "2"), class = "factor")),row.names = c(NA, 4L), class = "data.frame")
I have seen some functions that could work (e.g. aggregate), but I haven't found a solution so far.