I am trying to understand how to write a loop in R to rename a variable number of data frames.
If I run this code:
library("readxl")
path <- readxl_example("datasets.xls")
MyObject<-lapply(excel_sheets(path), read_excel, path = path)
I get an object that contains 4 tibbles. If I want to rename them as File1 - File4, I can use
File1<-MyObject[[1]]
And so on for each one separately. However, I am dealing with files that have varying numbers of worksheets, and so end up with variable numbers of dataframes in my object. So my question is; how do I tell R to rename each tibble as File1, File2, etc for as many tibbles are in the object? I would welcome a specific answer, but if there is a tutorial out there that talks about writing loops (for beginners) that people recommend, I would welcome that as well.