My question is similar to this question:How to change the order of display of list.files(): for example based on part of the whole name of files
but my case is differnt. I used the solution provided:
a=a[order(gsub('.*_(\\d{8})[.].*','\\1',a))]
but did not work for my case because the naming in my case is different from that provided in that question.
I have several files in a directory. The naming of the files is complex,for instance :
file.img
file.img
I want to list the files so that I can work with them, it seemed that R listed them in a certain order. R ordered the files alphabetically even if the data is not ordered correctly.for example these two names of files:
How can I tell R to change the default display of list.files , and order the files based on _yearmonthday only which represents yearmonthday in all files:
to list files in R we use this :
I used:
mixsort
but did not ordered them as I want