[R] Odp: export results

jim holtman jholtman at gmail.com
Thu Feb 25 17:38:10 CET 2010


If your data can fit in memory, consider creating a list of the
intermediate values and then 'cbind'ing the result into a matrix that
you want to write out.

result <- lapply(1:100, function(x) .... your function ....)
# if everything is the same size
result <- do.call(cbind, result)

On Thu, Feb 25, 2010 at 10:44 AM, Petr PIKAL <petr.pikal at precheza.cz> wrote:
> Hi
>
> r-help-bounces at r-project.org napsal dne 25.02.2010 12:42:46:
>
>>
>> Hi all,
>>
>> I am looping through a function for 100 time in the middle of my code,
> and I
>> want to output the results from this function. Is there a way to write
> the
>> results into a txt or csv fil? For example, I write the results from the
>> first loop to the first column of a spreadsheet and the results from the
>> second loop to the second coclumn of a spreadsheet etc.
>
> make a data frame, let say res
>
> res=as.data.frame(matrix(NA, n, 100)) #predefine data frame
>
> for (i in ...) {
>
> some stuff
> res[,i] <- some function result
> }
>
> write.table(res,....)
>
> Regards
> Petr
>
>
>
>
>>
>> Thank you very much,
>> Wendy
>> --
>> View this message in context:
> http://n4.nabble.com/export-results-tp1568880p1568880.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.
>
> ______________________________________________
> 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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?



More information about the R-help mailing list