I'm not sure I completely understand your question, but I think the solution to your problem is the reshape function in the reshape package. Here is a silly example of how it would work:
> V<-matrix(rbinom(15,4,.5),nrow=3) > X<-data.frame(A=c("A","B","C"),V=V) > X A V.1 V.2 V.3 V.4 V.5 1 A 1 2 3 3 3 2 B 4 3 0 2 2 3 C 2 3 2 1 2 > reshape(X,direction="long",varying=c("V.1","V.2","V.3","V.4","V.5")) A time V id 1.1 A 1 1 1 2.1 B 1 4 2 3.1 C 1 2 3 1.2 A 2 2 1 2.2 B 2 3 2 3.2 C 2 3 3 1.3 A 3 3 1 2.3 B 3 0 2 3.3 C 3 2 3 1.4 A 4 3 1 2.4 B 4 2 2 3.4 C 4 1 3 1.5 A 5 3 1 2.5 B 5 2 2 3.5 C 5 2 3 Your two columns of interest are A and V. The time column lets you know from which column the V came. -tgs On Fri, Apr 16, 2010 at 6:35 AM, mhalsham <mhals...@bradford.ac.uk> wrote: > > Hi every one Im new to R and I cant figure our how to use the loop to do > the > following task, any help would be very kind of every one. > I have a file called (table3.txt) that contains over 1000 row and over 40 > columns. > So for example first row would look like that > > Deafness, EYA4, DIAPH1, MYO7A, TECTA, COL11A2, POU4F3, > MYH9, ACTG1, > MYO6 > > I want the loop stamens to loop thro each row and take first cell which is > (Deafness and second which is EYA4) and but it on the button of the file > and > then take the first cell which is (Deafness again and the third cell which > is the DIAPH1) and put it on the button of the file. And so on till I end > up > with two columns one consists all the disease and one consist all the > genes. > > -- > View this message in context: > http://n4.nabble.com/R-loop-tp1979620p1979620.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]]
______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.