不要删除 kable 函数中的空格 [英] Do not remove spaces in kable function

查看:40
本文介绍了不要删除 kable 函数中的空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发了几个回归模型,并希望将它们显示在表格中.回归系数及其后面的显着性水平显示在列中.我把系数和显着性水平贴在一起,每个回归模型有一列.

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=" ")

我在 R 中运行表格时的输出是正确的,但在 RMarkdown 中使用 kable 函数时,输出如下所示:

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?

提前致谢!

推荐答案

我问了一个类似的此处的问题 带有可重现的示例.

I asked a similar question here with a reproducible example.

我从@allan-cameron 收到的回答是:这不是 kable 问题.这就是 html 的行为方式.如果您想在文本中添加额外的空格,您需要将 " " 添加到您的文本中.将此作为粘贴分隔符,并确保将 escape = FALSE 置于 kable 中:"

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.

这篇关于不要删除 kable 函数中的空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆