Re: [R] storing output data from a loop that has varying row numbers

From: Joris Meys <jorismeys_at_gmail.com>
Date: Wed, 02 Jun 2010 12:16:07 +0200

Hi Ross,

the trick is especially split() and unsplit(). Split() splits up the dataframe based on the combined factors, unsplit() transforms it to a dataframe again. This way you can do the calculation for a set of mini-dataframes that contain only the information for 1 combination of the factors.

lapply is the apply-function specifically for lists. As split() gives you a list of dataframes, lapply loops through those dataframes the appropriate way. You can see that for yourself by doing str(seal_list).

Hope this clears things out a bit.
Cheers
Joris

On Wed, Jun 2, 2010 at 9:55 AM, RCulloch <ross.culloch_at_dur.ac.uk> wrote:

>
> Hi Jorvis,
>
> Many thanks for sorting that! I haven't seen it done that way before, so
> I'll have to look in to the properties of lapply a bit more to get a full
> appreciation of other approaches to looping data in R.
>
> Thanks again for your help, it is much appreciated,
>
> Ross
> --
> View this message in context:
> http://r.789695.n4.nabble.com/storing-output-data-from-a-loop-that-has-varying-row-numbers-tp2238396p2239711.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.
>

-- 
Joris Meys
Statistical Consultant

Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

Coupure Links 653
B-9000 Gent

tel : +32 9 264 59 87
Joris.Meys_at_Ugent.be
-------------------------------
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

	[[alternative HTML version deleted]]

______________________________________________
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.
Received on Wed 02 Jun 2010 - 10:20:24 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 02 Jun 2010 - 10:40:26 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive