Timitrov
Timitrov

Reputation: 221

Do not remove spaces in kable function

I have developed several regression models and want to present them in a table. The regression coefficients and, behind them, the significance levels are shown in the columns. There is one column for each regression model I have put thethe coefficients and significance levels together with paste.

paste(2.44," . ", sep=" ") or paste(1.33," * ", sep=" ") or paste(1.33,"   ", sep=" ")

The output when I run the table in R is correct but while using the kable function in RMarkdown the output looks like this:

3.99 ***  
 2.44  *   
    4.66 

But I want to display the results neatly like this:

 3.99 ***  
 2.44  *   
 4.66 

What can I do to solve this problem?

Thanks in advance!

Upvotes: 0

Views: 559

Answers (1)

Kodiakflds
Kodiakflds

Reputation: 623

I asked a similar question here with a reproducible example.

The answer I received from @allan-cameron was: "This is not a kable problem. This is how html behaves. If you want to add extra spaces in text you need to add " " to your text. Make this your paste separator, and ensure you turn escape = FALSE inside kable:"

That solution worked well for me.

Upvotes: 2

Related Questions