mardi 24 février 2015

(Language: R) How to get list.files to read in an array of files in the same order as Windows

Is there a way to list files in R as it is listed in Windows when sorted by "Name"?


For instance, say I have a Directory (henceforth "testDir") that has the following files:



1.txt
2.txt
3.txt
11.txt
111.txt


If I do the following in R:



testFiles = list.files(path = testDir, full.names = F)


testFiles will have the following output:



> testFiles
[1] "1.txt" "11.txt" "111.txt" "2.txt" "3.txt"


However, I would like it to be orderer as such:



"1.txt" "2.txt" "3.txt" "11.txt" "111.txt"


Is there another way of reading in these files? It should be noted that the timestamp for these files are not in any specific order.


Aucun commentaire:

Enregistrer un commentaire