Re: [R] data managment

From: yohannes alazar <hannesalazar_at_gmail.com>
Date: Fri 16 Jun 2006 - 04:29:04 EST

Thank you very much this does the work exactlly. regards Hannes

On 6/15/06, Adaikalavan Ramasamy <ramasamy@cancer.org.uk> wrote:
>
> 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
> >
>
>

        [[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 Received on Fri Jun 16 04:33:35 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:11 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.