0

I'll be honest, I think the title of this question might be the most confusing title on here but I didn't know how else to word it.

So in this example, let's just say I have two lists. Here is an example of the two lists (My real data has ~100 lists)

PNVKM2224G <- list(type = "rect", fillcolor = "#F190C5", line = list(color = "#F190C5", 
                                                       width = 1), opacity = 1, x0 = 76, x1 = 224, xref = "x", y0 = -0.16, 
     y1 = 0.16, yref = "y", layer = "below")

AJNKL7864N <- list(type = "rect", fillcolor = "#F190C5", line = list(color = "#F190C5", 
                                                                      width = 1), opacity = 1, x0 = 224, x1 = 4417, xref = "x", 
                    y0 = -0.16, y1 = 0.16, yref = "y", layer = "below")

so what I have done in the past to create a new list is something like this

big.list.of.lists <- list(PNVKM2224G, AJNKL7864N)

However, my actual data is so large at this point that it's just going to take too long to type out all the list names to create my new list of lists. So I figured I could make a list of all the list names that I want to combine. Here is an example of my list of list names

list.of.list.names <- list("PNVKM2224G", "AJNKL7864N")

I figured I could do something like this to use list.of.list.names to create my list of lists

big.list.of.lists <- list(list.of.list.names)

but this doesn't work. I tried looking around here to see if someone else has asked this question but I didn't have any luck. If there are any questions about what exactly I am asking, let me know. I understand that this is kind of a confusing question.

neuron
  • 1,775
  • 1
  • 11
  • 24
  • 1
    Use `mget(list.of.list.names)` though you want to make sure your input is a simple vector. `list.of.list.names – MrFlick Aug 20 '21 at 03:53
  • It doesn't seem the `mget` puts the lists in the same format as if you were to do `list(PNVKM2224G, AJNKL7864N)` – neuron Aug 20 '21 at 04:24
  • 1
    Well, `mget()` returns a named list by default. If you need it to be unnamed you can do `unname(mget(list.of.list.names))` but usually the names are more helpful that not. If that's not the difference, what exactly is the difference you see? See `a – MrFlick Aug 20 '21 at 04:26
  • @MrFlick Bingo, using `unname` worked like a charm. Feel free to turn this into an answer and I would be happy to select it as the correct answer. – neuron Aug 20 '21 at 04:33

0 Answers0