-1

Is there a way in R to define data frames in a similar space.

So lets say I have an unknown number of data frames to be created (say there will be n data.frames) I want to define a space as such:

space<-data.frame.space()
for(i in 1:n) (
space[i]<-some.func(var1,var2)
)|

where some.func creates certain data.frames (in this case it downloads information from the internet), and then I get to call these data frames by saying

space[1] #or
space[2]
#etc

I know people somehow use environments for this, and in functions I see something of the sort. I just don't know how they do that.

asosnovsky
  • 2,158
  • 3
  • 24
  • 41

1 Answers1

1

I think you just want a simple list

space<-list()
for(i in 1:n) (
    space[[i]]<-some.func(var1,var2)
)

and then

space[[1]]
space[[2]]

Note the double bracket indexing. Using double brackets will return the data.frame. Using single brackets will return a list containing the data.frame.

MrFlick
  • 195,160
  • 17
  • 277
  • 295