I am trying to grow a list in R, where both the value and name of each entry is held in a variable, but it doesn't seem to work.
my_models_names <- names(my_models)
my_rocs=list()
for (modl in my_models_names) {
my_probs <- testPred[[modl]]$Y1
my_roc <- roc(Ytst, my_probs)
c(my_rocs, modl=my_roc) # <-- modl and my_roc are both variables
}
My list my_rocs
is empty at the end, even though I know that the loop iterates (my_roc
is filled in) Why?
On a related note, is there a way to do this without looping?