I have a matrix like this:
structure(list(Gene_ID = structure(c(1L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 2L), .Label = c("g1", "g10", "g2", "g3", "g4", "g5", "g6", "g7", "g8", "g9"), class = "factor"), Module_Color = structure(c(3L, 1L, 3L, 2L, 3L, 1L, 2L, 3L, 2L, 1L), .Label = c("blue", "green", "red"), class = "factor")), .Names = c("Gene_ID", "Module_Color"), class = "data.frame", row.names = c(NA, -10L))
I want get the row indices of occurrences of all different module colors and create a list "modIndices" which will contain the row indices of all different module colors, like this:
modIndices$red={1,3,5,8}
#as red color appears in row 1,3,5 and 8.
modIndices$blue={2,6,10}
modIndices$green={4,7,9}
Though I am able to get indices of a particular color using "which" function, I am unable to create the above list.
Please help....