R/e_read_data_subdir_into_lists.R
e_read_data_subdir_into_lists.Rd
Recurse through subdirectories returning either filenames or tibbles (data.frames) by reading csv, xls, or xlsx with e_read_data_files()
.
e_read_data_subdir_into_lists(
fn_path = ".",
fn_detect = c("csv$", "xls$", "xlsx$"),
sw_fn_or_dat = c("fn", "dat")[1],
sw_exclude_empty_dir = c(TRUE, FALSE)[1],
sw_dat_add_col_path_fn = c(TRUE, FALSE)[1],
sw_dat_print_fn_read = c(TRUE, FALSE)[2],
excel_sheets = "all",
sw_clean_names = c(TRUE, FALSE)[2],
sw_list_or_flat = c("list", "flat")[1],
excel_range = NULL,
excel_col_names = TRUE
)
Starting directory path
NULL for all. File specification, used by stringr::str_detect()
, usually specifying file extensions.
Return filenames or tibbles (data.frames)
T/F exclude empty directories
T/F for data, add two columns specifying the directory (DIR__
) and filename (FILE__
)
T/F print file names and dimensions as the files are read
"all" for all sheets, or a list of numbers "c(1, 2)
"; applies to all excel sheets. Passed to e_read_data_files()
.
For data, T/F to clean column names using janitor::clean_names
Hierarical list or a "flat" 1-level list
When reading Excel files, NULL reads entire sheet, a range is specified as in readxl::read_xlsx
. Applies to all files.
Specified as in readxl::read_xlsx
. Applies to all files.
fn_names Either a structured list of filenames or of tibbles
if (FALSE) {
# # all file names
# e_read_data_subdir_into_lists(
# fn_path = "./data-raw/dat_subdir"
# , fn_detect = NULL
# , sw_fn_or_dat = c("fn", "dat")[1]
# , sw_exclude_empty_dir = c(TRUE, FALSE)[1]
# )
# # selected file names
# e_read_data_subdir_into_lists(
# fn_path = "./data-raw/dat_subdir"
# , fn_detect = c("csv$", "xls$", "xlsx$")
# , sw_fn_or_dat = c("fn", "dat")[1]
# , sw_exclude_empty_dir = c(TRUE, FALSE)[1]
# )
# # selected data
# e_read_data_subdir_into_lists(
# fn_path = "./data-raw/dat_subdir"
# , fn_detect = c("csv$", "xls$", "xlsx$")
# , sw_fn_or_dat = c("fn", "dat")[2]
# , sw_exclude_empty_dir = c(TRUE, FALSE)[1]
# , sw_dat_add_col_path_fn = c(TRUE, FALSE)[1]
# , sw_dat_print_fn_read = c(TRUE, FALSE)[1]
# , sw_clean_names = c(TRUE, FALSE)[2]
# , sw_list_or_flat = c("list", "flat")[1]
# )
# # selected data, flatten the directory structure
# e_read_data_subdir_into_lists(
# fn_path = "./data-raw/dat_subdir"
# , fn_detect = c("csv$", "xls$", "xlsx$")
# , sw_fn_or_dat = c("fn", "dat")[2]
# , sw_exclude_empty_dir = c(TRUE, FALSE)[1]
# , sw_dat_add_col_path_fn = c(TRUE, FALSE)[1]
# , sw_dat_print_fn_read = c(TRUE, FALSE)[1]
# , sw_clean_names = c(TRUE, FALSE)[2]
# , sw_list_or_flat = c("list", "flat")[2]
# )
}