From: Adaikalavan Ramasamy <ramasamy_at_cancer.org.uk>

Date: Thu 15 Jun 2006 - 20:46:20 EST

out

R-help@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu Jun 15 20:50:42 2006

Date: Thu 15 Jun 2006 - 20:46:20 EST

If your df contains your data, try

tmp <- cbind( paste(df[ ,1], df[ ,2], sep=":"),

paste(df[ ,3], df[ ,4], sep=":") ) tmp <- t( apply(tmp, 1, sort) )

out <- data.frame( do.call(rbind, strsplit( tmp[,1], split=":" )),

do.call(rbind, strsplit( tmp[,2], split=":" )) )colnames(out) <- colnames(df)

out

Regards, Adai

On Wed, 2006-06-14 at 16:35 +0100, yohannes alazar wrote:

> First I would really like to thank the mailing list for help I got in the

*> past, as a new to R I am really needing some support on hoe to code the
**> following problem.
**>
**>
**>
**> I am trying to sort some data I have in a big file. The file has 4 columns
**> and 19000 rows. An example of it looks like this:-
**>
**>
**>
**> G 0.892 A 0.108
**>
**> G 0.883 T 0.117
**>
**> T 0.5 C 0.5
**>
**> A 0.617 G 0.383
**>
**> G 0.925 A 0.075
**>
**> A 0.967 G 0.033
**>
**> C 0.883 T 0.117
**>
**> C 0.633 T 0.367
**>
**> G 0.95 A 0.05
**>
**> C 0.742 G 0.258
**>
**> G 0.875 T 0.125
**>
**> T 0.167 C 0.833
**>
**> C 0.792 A 0.208
**>
**>
**>
**> Columns one and three are alphabets while three and four are their
**> corresponding values.
**>
**> I wanted to sort this data so that my first and third columns are in
**> alphabetic order. For example in the first row the order is "G" then "A".
**> This is not in alphabetic order therefore we swap them along with their
**> values and it becomes:
**>
**> A 0.108 G 0.892
**>
**> Row two looks fine but row three needs the same rearrangement as row one.
**> And the final out put looks like:
**>
**> A 0.108 G 0.892
**>
**> G 0.883 T 0.117
**>
**> C 0.5 T 0.5
**>
**> A 0.617 G 0.383
**>
**> A 0.075 G 0.925
**>
**> A 0.967 G 0.033
**>
**> C 0.883 T 0.117
**>
**> C 0.633 T 0.367
**>
**> A 0.05 G 0.95
**>
**> C 0.742 G 0.258
**>
**> G 0.875 T 0.125
**>
**> C 0.833 T 0.167
**>
**> A 0.208 C 0.792
**>
**> Please some help with the relevant command names or a technique to code this
**> task.
**>
**> Thank you in advance
**>
**> Regards Hannes
**>
**> [[alternative HTML version deleted]]
**>
**> ______________________________________________
**> R-help@stat.math.ethz.ch mailing list
**> https://stat.ethz.ch/mailman/listinfo/r-help
**> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
**>
*

R-help@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu Jun 15 20:50:42 2006

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.1.8, at Fri 16 Jun 2006 - 06:12:08 EST.

*
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help.
Please read the posting
guide before posting to the list.
*