Another option:
require(gtools)
?mixedsort
> mixedsort(fileNames)
[1] "A1" "A2" "A10" "B1" "B2" "B10"
--
David
On Jul 18, 2010, at 5:16 AM, Duncan Mackay wrote:
Hi
Yes it is possible- one way is:
fileNames[order(sprintf("%02s", sub("[[:upper:]]","", fileNames)))]
[1] "A1" "B1" "A
Hi
Yes it is possible- one way is:
fileNames[order(sprintf("%02s", sub("[[:upper:]]","", fileNames)))]
[1] "A1" "B1" "A2" "B2" "A10" "B10"
Regards
Duncan
Duncan Mackay
Department of Agronomy and Soil Science
University of New England
ARMIDALE NSW 2351
Email home: mac...@northnet.com.au
A
> I get some file names by list.files().
> These names are in alphabetical order.
> I want to change it to logical numeric order.
> Example:
> > fileNames <- c("A10", "A1", "A2", "B1", "B2", "B10")
> > sort(fileNames)
> [1] "A1" "A10" "A2" "B1" "B10" "B2"
> I want to have:
> "A1" "A2" "A1
thanks a lot, it works.
you wrote:
> library(gtools)
> ?mixedorder
>
> --- On Sat, 7/17/10, Sebastian Gibb wrote:
> > From: Sebastian Gibb
> > Subject: [R] sort file names in numerical order
> > To: r-help@r-project.org
> > Received: Saturday, July 17, 201
On Sat, Jul 17, 2010 at 4:31 AM, Sebastian Gibb wrote:
> Hello,
>
> I get some file names by list.files().
> These names are in alphabetical order.
> I want to change it to logical numeric order.
> Example:
>> fileNames <- c("A10", "A1", "A2", "B1", "B2", "B10")
>> sort(fileNames)
> [1] "A1" "A10
library(gtools)
?mixedorder
--- On Sat, 7/17/10, Sebastian Gibb wrote:
> From: Sebastian Gibb
> Subject: [R] sort file names in numerical order
> To: r-help@r-project.org
> Received: Saturday, July 17, 2010, 4:31 AM
> Hello,
>
> I get some file names by list.files().
Hello,
I get some file names by list.files().
These names are in alphabetical order.
I want to change it to logical numeric order.
Example:
> fileNames <- c("A10", "A1", "A2", "B1", "B2", "B10")
> sort(fileNames)
[1] "A1" "A10" "A2" "B1" "B10" "B2"
I want to have:
"A1" "A2" "A10" "B1" "B2" "B1
7 matches
Mail list logo