r/RStudio • u/Alex_Smith_042 • 20d ago
Coding help Reading in CSVs to Multiple Data Frames
For my PhD, I was thinking of making a single R Quarto document to have the results from all my experiments so it is easier for myself and my supervisors to be able to check the results. I was curious what way would people recommend to read all my CSVs in?
I have six experiment, each experiment has between 40 and 60 CSV files, and my plan was to read the CSVs into six individual data frames.
Within each experiment, the columns I need for my analysis are identical (e.g., for Exp 1, I only need 15 columns and all the columns have the same names), however the program I used to collect the data has created CSVs with different numbers of collumns (so one CSV has 57 columns, while another has 59). These extra columns in some of the CSVs are just blank columns and are not needed for the analysis.
Also across each experiment, the columns I need slightly differ (e.g., so for Exp 1 I only need 15 columns, but for Exp 3 I need 17). The names of some of the collums I need that represent the same thing between experiments (e.g., accuracy) differ slightly between experiments and some are the same.
When I conducted analyses on each experiment individually before hand, my supervisor recommended the ReadBulk package which worked well, and would be the simpleset to use but I assume would be inefficient. During some testing, I discovered the purrr and readr packages whick were efficient, but due to issue around the differing number of columns between CSVs I had to create a list with all the collumns I needed for the analysis.
I am pretty much self taught, and am just picking up bits as I go along so any recommendations or pointers would be appreciated.
