[R] Loop Help

Jeff Newmiller jdnewmil at dcn.davis.CA.us
Mon Jun 18 16:16:42 CEST 2012


Then don't do that.

write.csv is designed to write a complete matrix or data frame in one call.  Combine your list of matrices into one (e.g. using sapply) and write that in one call afterward rather than piecewise as you do the calculations.
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.

"@ngel" <aggelopoulos at gmail.com> wrote:

>Hello Jim
>thank you so much for your response.
>When I use write.csv, on the csv file is saved only the last loop
>So when I write 
>
>results.matrix <- apply(degree_w(net.static[[i]]), 2, mean)
>write.csv(results.matrix, file = "results.csv")
>
>instead of getting a 550 line document with all loop results, I only
>get the
>last one!
>Could you please help me?
>Thank you so much in advance
>
>--
>View this message in context:
>http://r.789695.n4.nabble.com/Loop-Help-tp4633558p4633699.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