The code in this question and the datasets used in the code can be found in my GitHub Repository for this project.
I have loaded a set of 20 individual csv file formatted datasets into R using the following code:
# these 2 lines together create a simple character list of
# all the file names in the file folder of datasets you created
directory_paths <- "~/GMU folders (local)/DAEN_698/other datasets/sample obs(20 csvs)"
filepaths_list <- list.files(path = directory_paths, full.names = TRUE, recursive = TRUE)
> head(filepaths_list, 4)
[1] "C:/Users/Spencer/Documents/GMU folders (local)/DAEN_698/other datasets/sample obs(20 csvs)/0-3-1-1.csv"
[2] "C:/Users/Spencer/Documents/GMU folders (local)/DAEN_698/other datasets/sample obs(20 csvs)/0-3-1-10.csv"
[3] "C:/Users/Spencer/Documents/GMU folders (local)/DAEN_698/other datasets/sample obs(20 csvs)/0-3-1-11.csv"
[4] "C:/Users/Spencer/Documents/GMU folders (local)/DAEN_698/other datasets/sample obs(20 csvs)/0-3-1-12.csv"
While the actual filefolder full of csvs on the other hand looks like this:
As you can see, they are out of order. It is ordering them based on the individual digit in the last of the 4 descriptors for each dataset.
How can I reorder their names to be arranged correctly as in the attached photo?
I was also suggested to use this on here before:
# reformat the names of each of the csv file formatted dataset
DS_names_list <- basename(filepaths_list)
DS_names_list <- tools::file_path_sans_ext(DS_names_list)
> DS_names_list
[1] "0-3-1-1" "0-3-1-10" "0-3-1-11" "0-3-1-12" "0-3-1-13" "0-3-1-14" "0-3-1-15" "0-3-1-16"
[9] "0-3-1-17" "0-3-1-18" "0-3-1-19" "0-3-1-2" "0-3-1-20" "0-3-1-3" "0-3-1-4" "0-3-1-5"
[17] "0-3-1-6" "0-3-1-7" "0-3-1-8" "0-3-1-9"
But any alteration to this will not reorder or sort the actual file path list itself.
p.s. Each of the numbers in each of the filenames indicates a property of the underlying regression model which truly characterizes the data within that csv file in the following manner where their names are a11 n1-n2-n3-n4 in the following manner:
n1 indicates the degree of multicollinearity among all regressors (can be 0, 0.4 or 1) n2 indicates the true number of regressors in the underlying structural model n3 indicates the Error Variance for the true model n4 indicates the # random variation of the possible datasets which could be created with the following 3 characteristics from 1-500 for each of the previous conditions