Skip to content
Prev 376914 / 398502 Next

Reorder file names read by list.files function

You can paste the directory names, dir.names(files), back on, with
file.path(), after you do the sorting.  A better idiom is to use order()
instead of sort() and usng order's output to subscript file.names.  E.g.,
the following sorts by year and month number.
"C:/tmp/October_2016.PDF")
[1] "June_2018"    "May_2018"     "October_2016"
[1] "June"    "May"     "October"
Error: object 'month.names' not found
c("January","February","March","April","May","June","July","August","September","October","November","December")
[1]  6  5 10
[1] "C:/tmp/October_2016.PDF" "C:/tmp/May_2018.PDF"
 "C:/tmp/June_2018.PDF"




Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Wed, Oct 10, 2018 at 4:23 PM, Ek Esawi <esawiek at gmail.com> wrote: