0

I want to make a table with stargazer. First I assigned the outcome of my formula to rAgg. After this I want to make a stargazer table with the following commands:

a <- rAgg$ors.ctx
b <- rAgg$ors.indiv
c <-rAgg$lik
rbind(a,b,c)  

An example of the outcomes of a are: OR l95 u95 (Intercept) 0.007148468 0.006327645 0.008075768 statusscore14 0.996612498 0.971742666 1.022118825 meanGroente 1.068326524 1.046027113 1.091101319

This gives the outcome:

> rbind(a,b,c)
#                        OR          l95          u95
# (Intercept)   7.148468e-03 6.327645e-03 8.075768e-03
# statusscore14 9.966125e-01 9.717427e-01 1.022119e+00
# meanGroente   1.068327e+00 1.046027e+00 1.091101e+00
# pHerkomst     4.682304e-01 3.552017e-01 6.172260e-01
# pOuderPersoon 2.969725e+00 2.509198e+00 3.514775e+00
# c             4.686703e+03 4.686703e+03 4.686703e+03

However, I would prefer an outcome like this

                        rAgg      
(Intercept)   7.148468e-03 (6.327, 8.075)
statusscore14 9.966125e-01 (9.717, 1.022)
meanGroente   1.068327e+00 (1.046, 1.091)
pHerkomst     4.682304e-01 (3.552, 6.172)
pOuderPersoon 2.969725e+00 (2.509, 3.514)
c             4.686703e+03 (4.6867, 4.686)`

In other words, combine the three columns into one (and make use of brackets). I hope there is a convenient way to do this.

Help is much appreciated!

Keizer
  • 23
  • 1
  • 6

1 Answers1

1

Basically @rawr gave the answer already. Only a was missing in his comment. So the complete answer would be sprintf("%f (%.3f and %.3f)", a, b, c). PS: I avoid naming objects like functions (and c is a function).

Qaswed
  • 3,649
  • 7
  • 27
  • 47
  • Thanks. However, I got an error message: `Error in sprintf("%f (%.3f and %.3f)", a, b, c) : arguments cannot be recycled to the same length`. I tested and this is because the combination of a and b. Both have the same columns only a has one extra row. Why is this giving this error message? (ps. I added the layout of `a` in the question. And you are right about naming objects as functions. Changed it right away. – Keizer Jun 02 '16 at 13:53
  • If `a` has an extra row, one row has to be dropped in `a` (or added in `b` (and maybe also in `c`)). Let's say row 8 should be dropped, use `sprintf("%f (%.3f and %.3f)", a[-8], b, c)`. – Qaswed Jun 02 '16 at 13:57