I have the for loop calculating the RMSE for all of them which turns into 9 vectors with 1000 rows. How do I tell R to tell me which regression has the lowest RMSE for each simulation?

I tried using which.min(apply(train_selections,MARGIN=2,min)) but this just seems to give me the first column. I want the one with the min value and it to give it to me as the index number not the column name.

That's something we all experience. The best way to get help getting through it is to set up the problem with limited data sets, fewer variables and fewer simulations. The next step is to create the proper objects, the a workflow

Im so sorry to be annoying but @nirgrahamuk my professor won't have those packages when grading our homework :(. is there another way using just R to do this?

if (train_selections_min[i] == train_rmse_x1_1_sigma_1[i]){

train_lowest[i] = 1

} else if (train_selections_min[i] == train_rmse_x1_2_sigma_1[i]){

train_lowest[i] = 2

} else if (train_selections_min[i] == train_rmse_x1_3_sigma_1[i]){

train_lowest[i] = 3

} else if (train_selections_min[i] == train_rmse_x1_4_sigma_1[i]){

train_lowest[i] = 4

} else if (train_selections_min[i] == train_rmse_x1_5_sigma_1[i]){

train_lowest[i] = 5

} else if (train_selections_min[i] == train_rmse_x1_6_sigma_1[i]){

train_lowest[i] = 6

} else if (train_selections_min[i] == train_rmse_x1_7_sigma_1[i]){

train_lowest[i] = 7

} else if (train_selections_min[i] == train_rmse_x1_8_sigma_1[i]){

train_lowest[i] = 8

} else if (train_selections_min[i] == train_rmse_x1_9_sigma_1[i]){

train_lowest[i] = 9

}
where train_selections_min holds the minimum for each row and train_rmse_x1_x_sigma_1 is the value its checking against to see if its equal. It goes from side to side scanning but for some reason this doesnt work either

train_lowest is supposed to be a storage vector for the value of each column