I'm facing a problem with R. I created a certain amount of dataframes after a series of subsettings of my big species table, according to sex, collection moment, family etc... I saved them as .csv files in my datasets/csv/ directory, and as you can imagine it gets quite confuse. So I thought to save those dataframes as a list which, after saving it as an r object, I can load as an unique object when I do analysis in a separate RMarkdown file. This will avoid mistakes in loading .csv files and me getting mad to search and load the right file in the /csv directory.
So. After deleting the useless objects I have a situation like this (with more dataframes).
my_list <- replicate(n = 10, expr = {data.frame(x = rnorm(50), y = rnorm(50))}, simplify = F)
names(my_list) <- c(paste("ciao", c(1:10)))
list2env(my_list ,.GlobalEnv)
Obviously the names of the dataframes are not just ciao 1, 2 etc... but are different from each other. Now I would like to "come back" listing and naming each object with its name, something like
my_list2 <- list()
for (i in seq_along(ls())) {
my_data[["The name of i-th object"]] <- list="i-th object"
}
And here I faced the problem. How can I call just the name of the i-th object using ls() basing on its position, which I get from seq_along? I searched in the help page and in this and other websites, but I found nothing.
Thank you very much. Simone.