Re: [R] how to order each element according to alphabet

2011-07-15 Thread David Winsemius
On Jul 15, 2011, at 12:23 AM, onthetopo wrote: dd [,1] [,2] [1,] "OP" "SU" [2,] "XA" "YQ" sapply( lapply( + strsplit(dd, split=""), sort), + paste, collapse="") [1] "OP" "AX" "SU" "QY" The result is not what I intended since it is a single line. It should be: [,1] [,2] [1,] "OP" "SU

Re: [R] how to order each element according to alphabet

2011-07-15 Thread Dennis Murphy
Hi: Is this what you're looking for? Lines <- " ASG,UXW,AFODJEL E,TDIWE,ROFD" # Read in the above lines (for purposes of this example only) # Note the stringsAs Factors = FALSE option! df <- read.csv(textConnection(Lines), header = FALSE, stringsAsFactors = FALSE) closeAllConnections() dm <- as.

Re: [R] how to order each element according to alphabet

2011-07-14 Thread onthetopo
> dd [,1] [,2] [1,] "OP" "SU" [2,] "XA" "YQ" sapply( lapply( + strsplit(dd, split=""), sort), + paste, collapse="") [1] "OP" "AX" "SU" "QY" The result is not what I intended since it is a single line. It should be: [,1] [,2] [1,] "OP" "SU" [2,] "AX" "QY" -- View this message in conte

Re: [R] how to order each element according to alphabet

2011-07-14 Thread onthetopo
dd=rbind(c("OP", "SU"),c("XA", "YQ")) -- View this message in context: http://r.789695.n4.nabble.com/how-to-order-each-element-according-to-alphabet-tp3668997p3669194.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org

Re: [R] how to order each element according to alphabet

2011-07-14 Thread David Winsemius
On Jul 14, 2011, at 11:56 PM, onthetopo wrote: Thank you very much for your reply doctor. I tried to apply your command to my table but couldn't Would you please enlighten me on how to do this when 'lets2' is a 4X4 matrix for example. The message doesn't seem to be getting through. Let's s

Re: [R] how to order each element according to alphabet

2011-07-14 Thread onthetopo
Thank you very much for your reply doctor. I tried to apply your command to my table but couldn't Would you please enlighten me on how to do this when 'lets2' is a 4X4 matrix for example. -- View this message in context: http://r.789695.n4.nabble.com/how-to-order-each-element-according-to-alpha

Re: [R] how to order each element according to alphabet

2011-07-14 Thread David Winsemius
On Jul 14, 2011, at 11:19 PM, onthetopo wrote: Hi, There are many more patterns than VL to LV. In fact, too many to be listed manually. For example ML should be ordered as LM, QL should be ordered as LQ. The order is according to the alphabet. A more complete (reproducible) answer woul

Re: [R] how to order each element according to alphabet

2011-07-14 Thread onthetopo
Hi, There are many more patterns than VL to LV. In fact, too many to be listed manually. For example ML should be ordered as LM, QL should be ordered as LQ. The order is according to the alphabet. -- View this message in context: http://r.789695.n4.nabble.com/how-to-order-each-element-ac

Re: [R] how to order each element according to alphabet

2011-07-14 Thread David Winsemius
On Jul 14, 2011, at 9:18 PM, onthetopo wrote: Hi there, I have a large amino acid csv file like this: input.txt: P,LV,Q,Z P,VL,Q,Z P,ML,QL,Z Are you also asking how to read a comma separated file? ? read.csv # and read more introductory material There is a problem with this file, sin

[R] how to order each element according to alphabet

2011-07-14 Thread onthetopo
Hi there, I have a large amino acid csv file like this: input.txt: P,LV,Q,Z P,VL,Q,Z P,ML,QL,Z There is a problem with this file, since LV and VL are in fact the same thing. How do I order each element according to alphabetical order so that the desired output would look like: output.txt: