My question is simple and there a lot of "answers" with lapply which give me something I am not looking for. They are not useful because I get a list and then I have to do another loop to obtain the dataframes, and I run into the same problem: create several dataframes at once with serialized names. That is why I am asking a new question.
I have ONE excel file with 5 different sheets, I want to create 5 different dataframes.
library(openxlsx)
ln=list()
for (i in 2:6)
{
ln[[i]]<-read.xlsx("File.xlsx", sheet=i-1, startRow=3)
}
Then, I know I can do:
mo_1<-data.frame(ln[[2]])
and it looks like it will give me the right sheet file. However, I need to do this for all the sheets. My attempt is:
for (i in 2:6){
mo_[i]<-data.frame(ln[[i]])
}
and this brings me to the same problem as before. P
So I need 5 files: mo2, ...,mo6, and I want them to be DATAFRAMES (not lists).
Thank you.
JUST TO ADD why the other solutions do not work: -They do not seem to be making frames, they seem to be keep making lists and it seems I have to manually do the transformation.
Another way of phrasing this question is how to create data frames from a list using a loop.