I have a bunch of .csv files that I am merging into a single
data.frame . I'm looking to create a source column that identifies the row by a piece of the filename. In this case, my file names are set-up as "zagats_food.csv". I'm looking to get the piece before the _, and have that under a new source column. In this case it would be zagats. Here's the code I have so far using
library(here) library(tidyverse) restaurants <- fs::dir_ls(here::here("input_data"), regexp = "^.*food.*") %>% map_dfr(read_csv)
I am then doing all of my data wrangling in a pipe after the
Thanks in advance!