Displaying 10 results from an estimated 10 matches for "mixedorder".
2018 Mar 12
7
Equivalent of gtools::mixedsort in R base
Hi,
Searching for functions that would order strings that mix characters and numbers in a "natural" way (ie, "a1 a2 a10" instead of "a1 a10 a2"), I found the mixedsort and mixedorder from the gtools package.
Problems:
1- mixedorder does not work in a "do.call(mixedorder, mydataframe)" call like the order function does
2- gtools has not been updated in 2.5 years
Are you aware of an equivalent of this function in base R or a another contributed package (with correcti...
2018 Mar 12
0
Equivalent of gtools::mixedsort in R base
1- mixedorder does not work in a "do.call(mixedorder, mydataframe)"
call like the order function does
This is tangential, but do.call(order, mydataframe) is not safe to use in a
general purpose function either - you need to remove the names from
the second argument:
> d <- data.frame(method=c(...
2018 Mar 12
0
Equivalent of gtools::mixedsort in R base
...","a12","a100"))
> y
[1] "a1" "a10" "a100" "a12" "a2"
> mixedsort(y)
[1] "a1" "a2" "a10" "a12" "a100"
**Please read the docs!** They say that mixedsort() and mixedorder() both
take a **single vector** as the argument to be sorted or ordered and, as
the above indicates, they perform exactly as advertised. **Unlike
order()**. So of course your do.call() construction fails.
So presumably you have a data frame with multiple columns of mixed alpha
and numerics? (A...
2018 Mar 12
1
Equivalent of gtools::mixedsort in R base
...;a10", "a2" )
y <- c( "b10", "b2", "a12", "ca1" )
DF <- expand.grid( x = x, y = y )
# randomize
set.seed( 42 )
DF <- DF[ sample( nrow( DF ) ), ]
# missing from gtools
mixedrank <- function( x ) {
seq.int( length( x ) )[ gtools::mixedorder(x) ]
}
o <- do.call( order, lapply( DF, mixedrank ) )
DF[ o, ]
# or, as Bert suggests:
myrank <- function( v ) {
vu <- unique(v)
vl <- regmatches( vu,regexec("^([A-Za-z]+)(\\d+)$",vu))
alph <- sapply( vl, function(s) s[2] )
digt <- as.integer( sapply( vl,...
2018 Mar 12
0
Equivalent of gtools::mixedsort in R base
...t 12:15 AM, Sebastien Bihorel
<sebastien.bihorel at cognigencorp.com> wrote:
> Hi,
>
> Searching for functions that would order strings that mix characters and numbers in a "natural" way (ie, "a1 a2 a10" instead of "a1 a10 a2"), I found the mixedsort and mixedorder from the gtools package.
>
> Problems:
> 1- mixedorder does not work in a "do.call(mixedorder, mydataframe)" call like the order function does
> 2- gtools has not been updated in 2.5 years
>
> Are you aware of an equivalent of this function in base R or a another contrib...
2012 Feb 28
2
Error: could not find function "hier.part"
...s gtools::ddirichlet gtools::defmacro
gtools::even gtools::foldchange
gtools::foldchange2logratio
gtools::inv.logit gtools::invalid gtools::keywords
gtools::logit gtools::logratio2foldchange gtools::mixedorder
gtools::mixedsort gtools::odd gtools::permutations
gtools::permute gtools::quantcut gtools::rdirichlet
gtools::running gtools::scat
gtools::setTCPNoDelay
gtools::smartbind gtools...
2012 May 28
1
Why R order files as 1 10 100 not 1 2 3 ?
The code given below worked well. However, the problem is that when I typed
dir1 to see the results I found that R order the files as:
[1] "data1.flt" "data10.flt" "data100.flt" "data101.flt"
[5] "data102.flt" "data103.flt" "data104.flt" "data105.flt"
[9] "data106.flt" "data107.flt"
2010 Jul 17
4
sort file names in numerical order
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:
2006 Feb 24
3
Sorting alphanumerically
I'm trying to sort a DATAFRAME by a column "ID" that contains
alphanumeric data. Specifically,"ID" contains integers all preceeded
by the character "g" as in:
g1, g6, g3, g19, g100, g2, g39
I am using the following code:
DATAFRAME=DATAFRAME[order(DATAFRAME1$ID),]
and was hoping it would sort the dataframe by ID in the following manner
g1, g2, g3, g6, g19,
2009 May 29
3
IP-Address
Hi,
Is there any way to sort a tabel with a colum with IP-address?
table:
id rank color status ip
138 29746 yellow no 162.131.58.26
138 29746 red yes 162.131.58.16
138 29746 blue yes 162.131.58.10
138 29746 red no 162.131.58.17
138 29746 yellow no 162.131.58.14
138 29746 red no 162.131.58.13
138 29746 yellow no 162.132.58.15
139 29746 green no 162.252.20.69
140 29746 red yes