I have these lists: models_results_ZL, models_results_B2 and models_results_B4 that contain numbers.
For example:
> models_results_ZL
[1] 245.1907896 29.9200000 0.9000181 34.0000000
> models_results_B2
[1] 264.9851283 53.7100000 0.9163977 32.0000000
> models_results_B4
[1] 289.7529856 52.5600000 0.9229745 31.0000000
I have the list both_constr_satisfied that contains "B2","B4". This list is not static. It may contains different combinations of "ZL", "B2" and "B4".
For example:
> both_constr_satisfied
[1] "B2" "B4"
Regarding the values of both_constr_satisfied I want to get the first value of the corresponding models_results lists. e.g. For this example I want to get models_results_B2[1] and models_results_B4[1] and store them to a new list. e.g. new_list = [264.9851283, 289.7529856]
How can I concatenate strings and use them as a list name?
I'm trying the following code, but var_name is just a string not a list.
VQ_options=c()
for (option in length(both_constr_satisfied)){
assign(var_name, paste0("models_results_",both_constr_satisfied[option+1]))
VQ_options = var_name[1]
}
model_resultsandboth_constr_satisfiedlistsmodel_results. There are 3 different lists that have the same initial name.model_results_ZL,model_results_B2andmodel_results_B4. I want to concatenatemodel_resultswith the values ofboth_constr_satisfiedand use these as lists. I added examples of these. I will add also forboth_constr_satisfied.