0

I've created objects (within a for loop) and summarize them in a list at the end of each loop.

in1 = which(var1 == 1)
in2 = which(var1 == 2)
out1= which(var2 == 1)
out2= which(var2 == 2)
templist = list(in1, in2, out1, out2)

Every object in the list has no name now. I know I could fix this by using:

templist = list(name1 = in1, name2 = in2, name3 = out1, name4 = out2)

But I was wondering if there is as possibility to make this more automatically, like "taking the object's name as name of the list's element". In my opinion this seems obvious but to R it doesn't seem so obvious. I am sure there is a good reason for that, but anyway: Is there a fancy solution to automatically use the object's name as the element's name within the list?

Torsten
  • 23
  • 3

0 Answers0