[R] Creating nice looking lists: how?

Sergey Goriatchev sergeyg at gmail.com
Fri Sep 28 16:03:24 CEST 2007


Hello,

For my functions I want to create output similar in appearance to that
of what you get when you print a summary of lm model:

Residuals:
      Min        1Q         Median        3Q           Max
-0.209209 -0.043133  0.001793  0.044105  0.234750

Coefficients:
                 Estimate  Std. Error  t value    Pr(>|t|)
(Intercept)  0.981762   0.004089 240.103  < 2e-16 ***
Factor 1    -0.009581   0.006381  -1.501 0.134296
Factor 2    -0.008993   0.009182  -0.979 0.328163
Factor 3     0.029960   0.009547   3.138 0.001866 **
Factor 4    -0.026575   0.007370  -3.606 0.000363 ***
Factor 5    -0.004847   0.006382  -0.760 0.448138
Factor 6     0.005099   0.006483   0.786 0.432202
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

I want:
1) no $ before the list component names
2) component names that take values from outside variables
(ex.: number <- 10
       There are 'number' factors in the model:)

There is not much information on how to create nice output in terms of
lists, so I was looking for core to write the summary(lm) output, but
could not find much. Obviously, I can type summary.lm, but it does not
show how to create the name "Coefficients:"

Could someone give me pointers on how to create nice lists?

Thanks
Sergey



More information about the R-help mailing list