Re: [R] Writing to a file

2012-02-07 Thread Felicity
Thank you a lot for answering so fast!
but..what do you mean by example?
I 've mentioned above the loop I used and I also show how the file looks
like
'cause its huge.

the way i read the file is 
x=read.table(filename.txt,header=FALSE,sep=\t,fill=TRUE)
y=x[1:45,]
(i use only some rows in order to test if it works )

--
View this message in context: 
http://r.789695.n4.nabble.com/Writing-to-a-file-tp3070617p4364034.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.


Re: [R] Writing to a file

2012-02-07 Thread Felicity
Thanks a lot for the interest :)

My loop is the following 
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 == 3 ){
cat(y[i,1],  file = foo.csv,  \n)
}
 counter = 0

}

and after read.table(foo.csv)

I get 
  V1
1 45

which is the last result

why does it overwrite? how can I have all the results?

Eager to a reply from you!

--
View this message in context: 
http://r.789695.n4.nabble.com/Writing-to-a-file-tp3070617p4364149.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.


Re: [R] Writing to a file

2012-02-06 Thread Felicity
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_1 ...
Prot_9996
[1] Prot_10041
8527 Levels: Prot_0 Prot_1 Prot_10 Prot_100 Prot_1000 Prot_1 ...
Prot_9996
[1] Prot_10045
8527 Levels: Prot_0 Prot_1 Prot_10 Prot_100 Prot_1000 Prot_1 ...
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.

__
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.


Re: [R] Writing to a file

2012-02-06 Thread Felicity
maybe I could keep each line (having the strings) 
in a file or somewhere and then 
call a print function that prints them all together
from where I saved them?
Please let me know as soon as Possible!!
thank you!

--
View this message in context: 
http://r.789695.n4.nabble.com/Writing-to-a-file-tp3070617p4362340.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.


Re: [R] Writing to a file

2012-02-06 Thread Felicity
Honestly thank you for the prompt responding
and you are right I will tellyou what I want to do 
and not the way ..since I dont know much from R


I have a txt with Proteins

Prot_10035Func_0005874  Func_0016787  Func_0003774  Func_0006898
Func_0005856  Func_0005525  Func_0005737  Func_0003924  Func_0005515
Func_166  













Prot_10036Func_0005739  Func_0003735  Func_0006412  Func_0005763
Func_0005840  













Prot_10037Func_0005739  Func_0005515  














Prot_10039Func_0005576  Func_0009615  Func_0050832  Func_0005615
Func_0006955  Func_0042742  Func_0031640  Func_0006935  














Prot_1004