> filenames <- c("Q_Read_prist#[email protected]", "Q_Read_prist#[email protected]", 
> "Q_Read_prist#[email protected]")
> filenames <- gtools::mixedsort(filenames, numeric.type="decimal")
> filenames
[1] "Q_Read_prist#[email protected]"  "Q_Read_prist#[email protected]"  
"Q_Read_prist#[email protected]"

/Henrik

On Fri, Dec 4, 2015 at 7:53 AM, Boris Steipe <[email protected]> wrote:
> The thread below has a number of solutions. I personally like the one with 
> sprintf().
>    https://stat.ethz.ch/pipermail/r-help/2010-July/246059.html
>
>
> B.
>
> On Dec 4, 2015, at 5:51 AM, BARLAS Marios 247554 <[email protected]> wrote:
>
>> Hello everyone,
>>
>> I am an R rookie and I'm learning as I program.
>>
>> I am working on a script to process a large amount of data: I read a pattern 
>> of filenames in the folder I want and import their data
>>
>> filenames = list.files(path, pattern="*Q_Read_prist*")
>>
>> myfiles = lapply(filenames, function(x) read.xlsx2(file=x, sheetName="Data", 
>> header=TRUE, FILENAMEVAR=x))
>>
>> The problem is that R recognizes the files in a 'non human' order.
>>
>> Q_Read_prist#[email protected]   Q_Read_prist#[email protected]
>> Q_Read_prist#[email protected] Q_Read_prist#[email protected]
>> Q_Read_prist#[email protected] Q_Read_prist#[email protected]
>> Q_Read_prist#[email protected] Q_Read_prist#[email protected]
>> Q_Read_prist#[email protected] Q_Read_prist#[email protected]
>> Q_Read_prist#[email protected] Q_Read_prist#[email protected]
>> Q_Read_prist#[email protected] Q_Read_prist#[email protected]
>> Q_Read_prist#[email protected] Q_Read_prist#[email protected]
>> Q_Read_prist#[email protected] Q_Read_prist#[email protected]
>> Q_Read_prist#[email protected] Q_Read_prist#[email protected]
>> Q_Read_prist#[email protected] Q_Read_prist#[email protected]
>> Q_Read_prist#[email protected]   Q_Read_prist#[email protected]
>> Q_Read_prist#[email protected]   Q_Read_prist#[email protected]
>> Q_Read_prist#[email protected]   Q_Read_prist#[email protected]
>> Q_Read_prist#[email protected]   Q_Read_prist#[email protected]
>> Q_Read_prist#[email protected]   Q_Read_prist#[email protected]
>> Q_Read_prist#[email protected]   Q_Read_prist#[email protected]
>> Q_Read_prist#[email protected]   Q_Read_prist#[email protected]
>> Q_Read_prist#[email protected]   Q_Read_prist#[email protected]
>>
>> I tried to order them using order or sort but it doesn' seem to work. I have 
>> had the same issue in matlab but there I have a function to re-define the 
>> order in a "correct" way.
>>
>> Anyone knows of a smart way to sort these guys from 1 to 19 ascending or 
>> descending?
>>
>> Thanks in advance,
>> Mario
>>
>>       [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> [email protected] mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
> ______________________________________________
> [email protected] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

______________________________________________
[email protected] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to