I have created an index in another dataframe called "index"
I1 I2 I3 ...
1 3 5
2 4 6
3 5 7
I would like to subset another dataframe like so, and store each result as a separate dataframe
column_name_from_index <- main_df[index[,i], ]
So the end result is I get main_df indexed by columns of index, output being dataframes I1, I2, I3 and so on. I am getting stuck on splitting out my results (I am not grabbing column name at the moment, but I would like advice on how to do that).
s <- seq(1,30)
df <- main_df[FALSE, ] #creates an empty dataframe into which I can put all columns from main_df.
for(i in s){
df <- main_df[index[,i], ]
df[i, ]
}