Reading data from multiple files cont.

  • If you have many files you want to read in stored in the same directory, you can use the base R list.files() function to find the files for you by matching a pattern in the file names.
sales_files <- list.files("data", pattern = "sales\\.csv$", full.names = TRUE)
sales_files
## [1] "data/01-sales.csv" "data/02-sales.csv" "data/03-sales.csv"