Code
To make the answer generic, since that seems to be what you want, I would make a list
, then populate that list with dataframe
s.
my_list <- list()
for (i in seq(10)) {
my_list[[i]] = data.frame(x=runif(100), y=rnorm(100))
}
Explanation
Upon execution of this code, you will have a list
with 10 items, labelled 1 - 10. Each of those items is its own dataframe
, with 2 columns: one containing 100 uniform random numbers, and another containing 100 Gaussian random numbers (chosen from a standard normal distribution).
If you want to access, say, the third dataframe in the list, you'd simply type
my_list[[3]]
to get the contents of that dataframe.
(Lists use the double bracket notation in R, and you just have to "get used to it". It's fairly easy to figure out how to use them properly, though. E.g., my_list[3]
will return a list
with only 1 item in it, which is that third dataframe
. But my_list[[3]]
- notice the extra bracket - will return a dataframe
, the third dataframe
.)