将第二列向右对齐

问题描述

我想知道是否有人知道如何将 ggtexttable 列向右对齐?

这是一个简单的例子:

describe('my test description',() => {})

带有负号和小数的第二列看起来很糟糕,我想证明右边的第二列是合理的,提前致谢。

解决方法

利用 package documentation 我能做的最好的事情就是强制所有列向右。它还可能取决于您的 YAML 设置。你渲染到什么输出?自从我使用 html_document

以来,我可能得到了不同的结果

之前: enter image description here

之后:enter image description here

使用包指定表格主体样式,然后将其映射到 ggtexttable() 函数中。

tbody.style = tbody_style(hjust=1,x=0.9)

这是我的可重现解决方案

---
title: "Untitled"
author: "author"
date: "6/11/2021"
output: html_document
---

```{r setup}
library(ggpubr)

tbody.style = tbody_style(hjust=1,x=0.9)

df <- data.frame(Order = c(1:3),Name = c("Adam","Ben","Charlie"),Score = c(-.0041,8.00,9.123))


ggtexttable(df,rows = NULL,theme = ttheme(tbody.style = tbody.style))


```