Without creating a loop, the SPLIT function is the key to solving this problem.
Assuming that the factor column that you want to multiply (or a subgroup) is in the “coefficient” column of the data data “data”:
subsets<-split(data, data$factor, drop=TRUE)
This will create a list of subsets based on the coefficient value. The list will have the same length as the number of factors.
If you need to put each subset in a separate data frame, you can access them by following these steps:
group1<-subsets[[1]] group2<-subsets[[2]] ...
source share