Reputation: 302
Consider the following:
"16D" < "7A"
returns TRUE.
Why is that and how can I compare such character strings such that the number is compared first then the letter? This way the answer would be false because 16>7 and D>A?
Upvotes: 4
Views: 256
Reputation: 226362
Can you adapt this?
library("gtools")
(m <- mixedorder(c("16D","7A")))
## [1] 2 1
m[1] < m[2] ## FALSE
Upvotes: 5