向观星者描述表添加空间
当我在 R 中运行这段代码时,我得到了这个表格。但是这些数字彼此非常接近,我想知道是否有什么方法可以使它们之间的空间间隙更大?
代码: data %>% stargazer(type="html",title = "样本汇总统计",align = TRUE, out="变量描述.html")
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找不到通过
stargazer
函数的方法,但我找到了一个解决方法。我提供了两种方法来执行此操作,因为我不知道您是在 RMD 中使用它还是使用文件“Variables Descriptive.html”。如果您在 RMD 中使用 HTML 文件(在 R 代码之外),请按照修改 HTML 文件的说明进行操作。选项 1:使用 R Markdown
在到达执行此表的块之前添加以下内容 - 而不是在代码块中。
在执行表的代码块之前添加以下内容,而不是在代码块中添加以下内容。
立即在执行表的代码块之后添加以下内容,而不是在代码块中。
它看起来像这样:
看到输出后,您可以相应地调整宽度。根据屏幕尺寸,宽度会发生变化。然而,这也确保了间距均匀分散。
选项 2:使用 HTML 文件
您可以使用任何文本编辑器打开该文件。我通过转到“文件”选项卡、左键单击 .HTML 文件的名称,然后选择“在编辑器中打开”来使用 RStudio 的源窗格。
您现在将在源窗格中看到 HTML 代码。第一个标签是table标签;这就是我们要改变的。
目前它声明:
您将在此处添加内联 CSS。在代码中内联样式的末尾添加分号。在此示例中,我在
center
之后添加了一个分号。然后添加宽度:75%;
。确保您没有删除右括号或结束标记">
。保存文件。您可以从源内的菜单栏中选择预览 窗格中包含此 HTML 代码,或者您可以返回到文件 窗格和在浏览器中查看 与以前一样,查看视图的大小。屏幕将改变表格的大小
I couldn't find a way through the
stargazer
function, but I found a workaround. I've included two ways to do this because I don't know if you're using this in RMD or using the file "Variables Descriptive.html". If you're using the HTML file in RMD (outside of R code), follow the instructions for modifying the HTML file.Option 1: Using R Markdown
Add the following before you get to the chunk that executes this table—not in a code chunk.
Add the following immediately before the code chunk that executes the table add the following—not in a code chunk.
Add the following immediately after the code chunk that executes the table—not in a code chunk.
It will look something like this:
After you see the output, you can adjust the width accordingly. Depending on the screen size, the width will change. However, this also ensures that the spacing is evenly dispersed.
Option 2: Using the HTML file
You could use any text editor to open the file. I used the source pane of RStudio by going to the File tab, left-clicking on the name of the .HTML file, and selecting Open in Editor.
You will see the HTML code in your source pane now. The first tag is the table tag; that's what we're going to change.
Currently it states:
You are going to add the inline CSS here. Add a semi-colon to the end of the inline styles in the code. In this example, I added a semi-colon after
center
. Then addwidth: 75%;
. Make sure that you've not erased the closing parentheses or closing tag">
.Save the file. You can select Preview from the menu bar within the Source pane with this HTML code or you can go back to the File pane and View in Browser to see the changes. Just like before, the size of the viewing screen will change the size of the table.