[R] formatting a result table (number of digits)

Esmail esmail.js at gmail.com
Fri Apr 9 00:20:41 CEST 2010


Hello,

Is there an easy way to format the output of a result table that R
generates from a regression?  I like the table, but would like to
limit the number of decimal points in the entries if possible.

For instance I would like only 3 digits of precision for the Value,
Std.Error. (And if it would be easy to get rid of scientific notation,
that would be good to know too). So ideally keep the table/headers etc,
but chance the entries.

I've looked at format and print without much success.
I'm using  R 2.10.1 in a Linux environment.

Thanks,
Esmail


Below's an example of generating the table I am trying to format:

 > load('data.rda')
 > library(nlme)
 > ic <- lme(Ind_Cntrbn ~ 
D_Clb_Pbl+D_Club+Round+Ind_cntr_1+GR_cntr_1+D_Success_1+IndEarngs_1+D_Unfair_cntr_1+D_1st10rnds+D_Female+D_econ_gov+D_mjr_social+D_frshmn+D_junior+D_senior+UrbanArea+ParentEducation+Empathy+Lcs_Cntrl_Intn+Trust, 
random=~1|Group, data=Dataset)
 > s=summary(ic)
 > t=s$tTable
 > t
                        Value  Std.Error   DF     t-value      p-value
(Intercept)      5.683020304 0.78867419 2237  7.20578963 7.853134e-13
D_Clb_Pbl        0.193187682 0.25494452   22  0.75776363 4.566332e-01
D_Club           0.112745107 0.09636280 2237  1.17000650 2.421230e-01
Round           -0.096400805 0.01812222 2237 -5.31948107 1.144272e-07
Ind_cntr_1       0.340706093 0.04002901 2237  8.51147920 3.097981e-17
GR_cntr_1        0.033215293 0.01271829 2237  2.61161545 9.071799e-03
D_Success_1      2.210964800 0.38904872 2237  5.68300241 1.496038e-08
IndEarngs_1     -0.277758214 0.03903289 2237 -7.11600506 1.489839e-12
D_Unfair_cntr_1 -0.535979858 0.18280685 2237 -2.93194624 3.402644e-03
D_1st10rnds     -0.479775417 0.19375663 2237 -2.47617547 1.335331e-02
D_Female         0.076666269 0.12354518 2237  0.62055250 5.349573e-01
D_econ_gov      -0.282679230 0.12023002 2237 -2.35115350 1.880165e-02
D_mjr_social     0.149134543 0.12572505 2237  1.18619595 2.356709e-01
D_frshmn        -0.149157208 0.20609463 2237 -0.72373166 4.693062e-01
D_junior        -0.112917886 0.17455488 2237 -0.64689045 5.177692e-01
D_senior        -0.107570461 0.15088326 2237 -0.71293835 4.759583e-01
UrbanArea       -0.364410559 0.11988827 2237 -3.03958489 2.396486e-03
ParentEducation  0.098237171 0.05350248 2237  1.83612365 6.647201e-02
Empathy          0.042232476 0.08248236 2237  0.51201825 6.086888e-01
Lcs_Cntrl_Intn   0.132131306 0.08841098 2237  1.49451240 1.351828e-01
Trust           -0.003872427 0.08468412 2237 -0.04572789 9.635312e-01



More information about the R-help mailing list