Looping an addition of column with part of a file name

I have few files named "xxxxx yyy March 2019.csv, xxxxx yyy May 2020.csv " etc
I'm using this code to merge them all together:
files <- list.files(pattern = "*.csv")
df <- lapply(files, read_csv)
Bind <- bind_rows(df)
In this "Bind" dataset i want to create a column containing a month and a year (part of the name of original file) and i want to loop in in a manner that adding another file with similiar name format (maybe last 2 expressions, or somehow use date format) will automaticly update my dataframe.
No idea if that's even possible as i'm quite new to R but thank you in advance!

Hi, have a look at Reading and combining many tidy data files in R | Claus O. Wilke (clauswilke.com) and Gerke Lab | Import a Directory of CSV Files at Once Using {purrr} and {readr}

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.