I have a directory with multiple sub-directories within them and I did like to list the sub-directories then let the user choose the sub-directory he wants to read files within it.
I want the use to use the index to input his selection before the code continues to read files inside. Here is what I tried to list all sub-directories within the parent directory but I am stuck at how to use user raw input to select a sub-directory before reading the files within:
path = setwd("path to parent directory")
sub_dirs <- list.dirs(path, full.names = TRUE, recursive = TRUE)
#User raw input to be used here before listing files within
.....
#list all files
files <- dir(path, pattern = '\\.csv', full.names = FALSE)
#read files
tables <- lapply(files, read.csv)
Expected output is a code where I can list sub-directories within the parent directory then allow a user to input an index of the sub-directory he wants to read files inside it. then after user input then code proceeds to list csv files inside then read the files.