[R] A basic design question for R

Onur Uncu onuruncu at gmail.com
Sat Jun 16 19:14:38 CEST 2012


Thank you.  But isn't a data frame already a list? What is wrong with
adding a column to the existing data frame (a column with the
mortality curve matrices)?

Sorry if I am being difficult. Just want to learn good design in R.


On Sat, Jun 16, 2012 at 5:49 PM, steven mosher <moshersteven at gmail.com> wrote:
> use a list. or create new class which is a list
>
> On Jun 16, 2012 8:52 AM, "Onur Uncu" <onuruncu at gmail.com> wrote:
>>
>> Hello R Community,
>>
>> I have the following design question. I have a data set that looks
>> like this (shortened for the sake of example).
>>
>> Gender  Age
>>  M          70
>>  F           65
>>  M          70
>>
>> Each row represents a person with an age/gender combination. We could
>> put this data into a data frame.
>>
>> Now, I would like to do some actuarial analysis on this data set. To
>> do so, I need to create and store a mortality curve for each person in
>> the table (a mortality curve is a matrix with 2 columns: date and
>> survival probability). I can write a function that returns a mortality
>> curve given gender and age.  The question is the following: In what
>> data format should I store all these mortality curve objects? Should I
>> add a column to the data frame and each entry in that column is a
>> matrix (a mortality curve)? This way, the mortality curve would be
>> stored next to age/gender data in the data frame. However, I read in
>> several places that putting vectors/matrices as elements of a data
>> frame is a bad idea. I do not know why. What is a good design choice
>> in this instance please? How should I store the mortality curves?
>>
>> Thank you for your help.
>>
>> ______________________________________________
>> 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