I'm using the following function to import roughly 10 files from different years (all from the same folder) into r.
ed.attain.places_0_10_18 <-
list.files(path = "./ed_attainment/",
pattern = "*.csv",
full.names = T) %>%
map_df(~read_csv(., col_types = cols(.default = "c")))
This folder (ed_attainment/) contains the following csv files all the way to '17.
ACS_09_5YR_B19301_with_ann.csv
ACS_10_5YR_B19301_with_ann.csv
I want to add the year to each one of these files within the above function. Just importing one csv file the code would be
read_csv("ACS_09_5YR_B19301_with_ann.csv")%>%mutate(year = 09)
such that the year in the filename corresponds with the values in the new "year" variable.
Thanks much!