I have a dataframe X
id sales age
1 100 32
2 40 27
3 694 34
4 500 41
I would like to create a for loop
for (i in 1:4)
{
group[i]<- X[X$id==i, ]
}
I did this trivil for loop to describe the idea, however it needs to be edited. I want to get group1 as a data frame of sales and age in which id=1, and so on for other groups. Actually I search for a solution with a for loop because I will need it later.
Thanks !