I have information in a 3 dimensional list that I want to use to create
a table for a written report. 

 

The 3d list was created by applying the epiR function " epitest " to a
list of 8 2x2 tables using  lapply.  

The resulting list gives the 12 statistics with CIs,  that  generated by
epitest, for each of the 8 matrices (i9, i10, etc). 

 

The list has the following form:

 

Statslow$i9

$aprev

        est     lower    upper

1 0.2263884 0.2244714 0.228314

 

$tprev

       est     lower     upper

1 0.204388 0.2025413 0.2062442

 

Statslow$i10

$aprev

        est     lower    upper

1 0.227004 0.22545  0.228314

 

$tprev

       est     lower     upper

1 0.204388 0.2025413 0.2062442

 

 

I want to create a report that has a table in the following format:

                                   I9
i10                                      

                 Est   lower     upper                   Est  lower
upper                

 

aprev   0.23     0.22     0.23                           etc

tprev    0.2       0.20     0.21

etc

 

I have read and tried the tables package pdf and also the information at

http://www.r-statistics.com/tag/data-frame/ about cast() and
tabular.cast_df.r(), 

and also all the information I can find on nested tables, but have not
be successful.  

I have tried to use melt() on the 3D list (to create a dataframe
"statslow.d")  but get what seems more like S3 output :

 

  variable     value           L2                L1

1      est       0.2263884    aprev       i9

2    lower    0.2244714    aprev      i9

3    upper   0.2283140    aprev       i9

4      est       0.2043880     tprev      i9

5    lower    0.2025413    tprev       i9

6    upper   0.2062442    tprev       i9

 

When I try to use it with tables() I get errors

and I can't see how to use the tables function on it to get what I want.

Here is the tables() code that I have tried:

 

class(statslow.d)

[1] "data.frame"

> head(statslow.d)

  variable     value    L2  L1

1      est 0.2263884 aprev  i9

2    lower 0.2244714 aprev i9

3    upper 0.2283140 aprev i9

4      est 0.2043880 tprev i9

5    lower 0.2025413 tprev i9

6    upper 0.2062442 tprev i9

> tabular(statslow.d,L2~L1*variable)

Error in tabular.formula(as.formula(table, env = parent.frame()), ...) :


  data must be a dataframe, list or environment

> statslow.d<-as.data.frame(statslow.d)

> tabular(statslow.d,L2~L1*variable)

Error in tabular.formula(as.formula(table, env = parent.frame()), ...) :


  data must be a dataframe, list or environment

 

I would appreciate any help or hints anyone can give.

 

Jan Beckstrand

 


        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to