I have a directory of directories:
models <- dir("shopperml_pr_points")
> models
[1] "add_email_subscribers" "custom_domain" "email_campaign" "fb_connect" "gmb"
[6] "holdout" "ola" "ols" "post_to_fb" "sev"
Within each directory there is another directory of files e.g.
> list.files(paste0("shopperml_pr_points", "/", models[1]))
[1] "add_email_subscribers_task_completed_pr_auc_1547157396.csv" "add_email_subscribers_task_completed_pr_auc_1547157473.csv"
[3] "add_email_subscribers_task_completed_pr_auc_1547157551.csv" "add_email_subscribers_task_completed_pr_auc_1547157631.csv"
[5] "add_email_subscribers_task_completed_pr_auc_1547157712.csv"
I would like to create a list of dataframes, one for each directory within models. So, the first df will be based on directory "add_email_subscribers" and will be the combination of the 5 csv files above.
I wanted to use do.call(rbind, read.table) per this post but since I'm not in the same directory as where the files are actually read from, I'm finding this challenging. I wnet down a path of pasting a long string for each individual csv file but I wondered if there's a more elegant r solution that can already detect the full path of a file such as those within list.files(paste0("shopperml_pr_points", "/", models[1]))
.
How can I create a list of 9 dataframes based on the directories within models where each directory contains ~5 csv files and those 5 csv files should be collapsed into one dataframe?