Re: [R] sorting a dataframe

2015-06-21 Thread Bogdan Tanasa
Thank you all again. It works with : library("gtools") dat[mixedorder(A),] considering : A = c("A1","A10","A11","A2") B = c(1,2,3,4) dat = data.frame(A,B On Sun, Jun 21, 2015 at 10:52 AM, Bert Gunter wrote: > Diego: > > Nonsense! Look at the results of your code -- you have failed to order

Re: [R] sorting a dataframe

2015-06-21 Thread Bert Gunter
Diego: Nonsense! Look at the results of your code -- you have failed to order the results as had been requested by the OP. It's also unnecessarily complicated. The following suffices (where I have used regular expressions rather substring() to get the numeric part of the strings -- **assuming** th

Re: [R] sorting a dataframe

2015-06-21 Thread Diego Miro
Bogdan, Follow my suggestion. letter <- substring(A, 1, 1) number <- substring(A, 2, nchar(A)) new.data <- paste0(letter, formatC(as.numeric(number), width = 2, flag = "0")) Em 20/06/2015 21:21, "Bogdan Tanasa" escreveu: > Dear all, > > I am looking for a suggestion please regarding sorting a d

Re: [R] sorting a dataframe

2015-06-20 Thread Bogdan Tanasa
thank you all, it is working fine. happy weekend ;) ! On Sat, Jun 20, 2015 at 6:15 PM, David Winsemius wrote: > > On Jun 20, 2015, at 5:18 PM, Bogdan Tanasa wrote: > > > Dear all, > > > > I am looking for a suggestion please regarding sorting a dataframe with > > alphanumerical components : > >

Re: [R] sorting a dataframe

2015-06-20 Thread David Winsemius
On Jun 20, 2015, at 5:18 PM, Bogdan Tanasa wrote: > Dear all, > > I am looking for a suggestion please regarding sorting a dataframe with > alphanumerical components : > > let's assume we have : > > A = c("A1","A10","A11","A2") > B = c(1,2,3,4) > > C = data.frame(A,B) > > how could I sort C

[R] sorting a dataframe

2015-06-20 Thread Bogdan Tanasa
Dear all, I am looking for a suggestion please regarding sorting a dataframe with alphanumerical components : let's assume we have : A = c("A1","A10","A11","A2") B = c(1,2,3,4) C = data.frame(A,B) how could I sort C data.frame in such a way that we have at the end : C$A in the order : "A1", "