[R] Writing to a file

R. Michael Weylandt michael.weylandt at gmail.com
Tue Feb 7 17:27:52 CET 2012


As I said to you a while back, use append = TRUE.

Michael

On Tue, Feb 7, 2012 at 4:18 AM, Felicity <felicity-th at hotmail.com> wrote:
> 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 at 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.



More information about the R-help mailing list