Let's start with a simple example and will explain afterwards my needs. Consider this dataframe:
df <- structure(list(landmark = c("Akanthion", "Asterion R PARIETAL R",
"Asterion R TEMPORAL R", "Asterion R OCCIPITAL", "Asterion L PARIETAL L",
"Asterion L TEMPORAL L", "Asterion L OCCIPITAL", "Basioccipital anterior OCCIPITAL",
"Basioccipital anterior SPHENOID", "Basion"), MODULE = c(1, 4,
6, 7, 3, 5, 7, 7, 8, 7)), row.names = c("Akanthion", "Asterion R PARIETAL R",
"Asterion R TEMPORAL R", "Asterion R OCCIPITAL", "Asterion L PARIETAL L",
"Asterion L TEMPORAL L", "Asterion L OCCIPITAL", "Basioccipital anterior OCCIPITAL",
"Basioccipital anterior SPHENOID", "Basion"), class = "data.frame")
This dataframe is composed by two columns, one of them named as MODULE. This column has 7 different numbers which correspond to different groups (1, 3, 4, 5, 6, 7, 8)
I would like to get a vector for each group in MODULE with the row numbers they are.
For instance:
Group_7 <- c(4, 7:8, 10)
Group_4 <- c(2)
How can I do it automatically? To be honest, this a very small sample of my original dataframe, which is composed by 1487 rows.