0

I have a knitr_kable object. I want to put parenthesis on every value in every consecutive (2,4,6....) row. How I can do this.

out %>% knitr::kable(digits = 2, "pipe")
|              |     1|     2|     3|    4|     5|     6|     7|     8|     9|    10|  10-1|
|:-------------|-----:|-----:|-----:|----:|-----:|-----:|-----:|-----:|-----:|-----:|-----:|
|Excess Return | -0.20|  1.20|  0.97| 1.04|  0.77|  0.82|  0.79|  0.76|  0.76|  0.59|  0.79|
|NW t_Stat     | -0.28|  2.04|  3.02| 3.17|  2.56|  3.16|  3.09|  3.45|  3.86|  3.48|  1.13|
|FF5 Alpha     | -0.97|  0.43| -0.05| 0.02| -0.26| -0.17| -0.18| -0.19| -0.11| -0.11|  0.86|
|NW t_stats    | -1.41|  1.03| -0.26| 0.14| -2.75| -2.10| -2.32| -2.85| -1.77| -5.01|  1.26|
|MktRF beta    |  0.92|  1.00|  1.07| 1.08|  1.13|  1.11|  1.10|  1.08|  1.06|  0.99|  0.07|
|NW t_Stat     |  1.34|  2.40|  5.44| 6.49| 11.98| 13.51| 14.58| 16.13| 16.43| 46.90|  0.10|
|SMB5 beta     |  1.35|  1.34|  1.46| 1.26|  1.14|  1.03|  0.84|  0.69|  0.36| -0.16| -1.51|
|NW t_Stat     |  1.97|  3.22|  7.41| 7.56| 12.11| 12.44| 11.05| 10.28|  5.61| -7.37| -2.20|
|HML beta      |  0.52|  1.27|  0.48| 0.46|  0.55|  0.51|  0.36|  0.29|  0.22|  0.10| -0.42|
|NW t_Stat     |  0.75|  3.05|  2.46| 2.75|  5.82|  6.23|  4.70|  4.38|  3.47|  4.53| -0.62|
|CMA beta      |  0.43| -0.66|  0.15| 0.28|  0.11| -0.02|  0.10|  0.11|  0.13|  0.08| -0.34|
|NW t_stat     |  0.62| -1.59|  0.77| 1.65|  1.14| -0.28|  1.38|  1.61|  1.96|  3.92| -0.50|
|RMW beta      | -0.68| -0.25|  0.11| 0.08|  0.15|  0.24|  0.32|  0.35|  0.31|  0.17|  0.84|
|NW t_stat     | -0.98| -0.60|  0.54| 0.47|  1.56|  2.96|  4.22|  5.18|  4.75|  7.87|  1.23|
|Adj_r_square  |  0.14|  0.31|  0.64| 0.73|  0.87|  0.93|  0.94|  0.94|  0.93|  0.98|  0.09|
jeetkamal
  • 399
  • 2
  • 12
  • 1
    Please provide some sample data, code and some mock up output to display what you are trying to achieve. From your description it is not completely clear what you are trying to do. See [here](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) to learn about creating a reproducible example. – Till May 28 '21 at 16:12
  • I am not fully sure what you want to achieve. Conceptually, a column in a table should be of the same datatype. To add "stuff" like parantheses you can make all columns of type character and then run over the rows and use base R's `paste()`` or `{glue}`'s `glue()` function to put the desired string together. – Ray May 28 '21 at 19:18

0 Answers0