[R] Writing to a file

Felicity felicity-th at hotmail.com
Mon Feb 6 11:50:58 CET 2012


Dear All!!

I am also new in R 
and trying to write my results into a file I post here..hopefully is the
proper place
To be more secific  I have this loop 


counter = 0
 for (i in 1:nrow(y))
 {
 for (j in 1:ncol(y))
 {
 if (y[i,j]=="Func_0005634") {
         counter = counter + 1 }
 if(y[i,j]=="Func_0005737"){
         counter = counter + 1 } 
 if(y[i,j]=="Func_0005515"){
        counter = counter + 1 }
}
 if(counter == 2) {
	 k<-structure(list(print(y[i,1])), class = "data.frame")
}
 if(counter == 3 ){
    	 l<-structure(list(print(y[i,1])), class = "data.frame")
        }
 counter = 0
 }


for counter==2 or counter ==3 
I want to get print(y[i,1]) 
where in column 1 exists the name of the protein
whereas in the rest columns exist somewhere randomly the strings im looking
for 

I want to get the names of the proteins in a file and those that have either
2 or 3 functions be named as cancer.

the specific part of code gives me as a result in the command line this (is
a sample cause im working on 8500lines)
[1] Prot_10035
8527 Levels: Prot_0 Prot_1 Prot_10 Prot_100 Prot_1000 Prot_10000 ...
Prot_9996
[1] Prot_10041
8527 Levels: Prot_0 Prot_1 Prot_10 Prot_100 Prot_1000 Prot_10000 ...
Prot_9996
[1] Prot_10045
8527 Levels: Prot_0 Prot_1 Prot_10 Prot_100 Prot_1000 Prot_10000 ...
Prot_9996


which is fine i can see the names of the proteins but i cant use them so to
label them
When I try to write it in a file ..then is kept only the last result because
unfortunatelly 
he overwrites himself :(

How can I use those data? How can I write them in a file and add as an extra
column the word cancel
for those containing the specific functions?

Any hint you may give me it would be more than helpful for me!
Thank you a lot in advance! 
Looking forward to your reply :)


--
View this message in context: http://r.789695.n4.nabble.com/Writing-to-a-file-tp3070617p4360889.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list