Store graphics to a list without index

I am using a loop for generate data to be used in some plots, but the function computes results from 5 repetitions.
When a tried to insert the graphs in a list, only one graph from the last repetition is saved, because the list index is different from the loop index.
Is there a way to use an empty list without especify the index? (like function append for example)

To simplify, here is a pseudocode:

graphs_list <- list()

for(i in 1:4){
data_i <- data[[i]]
for(j in 1:5) {
predict_ANN_ij <- compute(ANN, rep = j)
plot_base <- tibble(observed, predict_ANN_ij)
graph <- ggplot(plot_base)

graphs_list[[...]] <- graph

The code is runnig right.
All graphs are printted correctly, but I need to store them inside an object to further use.
Can someone help me please!!

What's the advantage of not using an index? Just use an index! Index can be anything at all. e.g.

graphs_list[[paste(i,j)]] <- graph

Also, there is indeed an append function that can be used with lists. Did you check the help?

Because I need a different index for the list, and I tried to use other things. Still don't work.
I've tried the append function, didn't work for figures. And graphs_list[[paste(i,j)]] <- graph didn't work too.

What error message do you get? This should work fine.

I did a regression with i and j to use inside the list index, and worked! =D
Maybe there is an easier way, but I had to go on.
Thanks for the help!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.