I'm looking to use purr to create a year variable on my data sets and join them together. This example will illustrate the problem and what I have tired.
# files in the directory
files <- paste0("data/file_year_", 2015:2019, ".txt")
# map
files <- paste0("data_", 2013:2019, ".csv")
lst1 <- files %>%
map(~ read_csv(.x) %>%
mutate(year = str_extract(., "\\d{4}")))
The list now needs to be merged into a single data frame.
dat1 <- bind_rows(lst1, .id = 'grp')
However, I am getting the following error when I try to create the list:
Error in mutate_(.data, .dots = compat_as_lazy_dots(...)) :
argument ".data" is missing, with no default
In addition: Warning message:
In stri_extract_first_regex(string, pattern, opts_regex = opts(pattern)) :
argument is not an atomic vector; coercing
I tried searching for this error and nothing as helped so far. Any help would be greatly appreciated.