4

Is there a way to nicely format a the output of a quantile function in R when using Knitr to put everything together into an HTML or PDF? Typically, I have used Kable to make Knitr Tables nice with correct formatting.

e.g. quantile(data$x, (1:100)/100)

Displays this

## 1% 2% 3% 4% 5% 6% 7% 8% 9%

## 9.00 9.00 10.00 10.00 10.00 10.00 10.00 11.00 11.00

## 10% 11% 12% 13% 14% 15% 16% 17% 18%

## 11.00 11.00 11.00 11.00 12.00 12.00 12.00 12.00 12.00

Which is fine but some people misread it in some instances due to the lack of separators between each row. Any possible solutions?

guy
  • 1,021
  • 2
  • 16
  • 40

1 Answers1

4

kable does fine if you add names:

x <- rnorm(100)
q <- quantile(x, (1:10)/100)
kable(q, col.names = "Quantile")

(You'll probably want to change the default formatting in HTML, but that's a different issue.)

user2554330
  • 37,248
  • 4
  • 43
  • 90