Reputation: 353
I was wondering if anyone knows how to align a ggtexttable column to the right?
This is a brief example:
library(ggpubr)
df <- data.frame(Order = c(1:3),
Name = c("Adam", "Ben", "Charlie"),
Score = c(-.0041, 8.00, 9.123))
stable.p <- ggtexttable(df, rows = NULL, theme = ttheme("default"))
ggarrange(stable.p, ncol = 1, nrow = 1, heights = c(1, 1))
The second column with the negative sign and the decimals just looks bad, I would like to justify that second column to the right, thanks in advance.
Upvotes: 0
Views: 393
Reputation: 3252
Utilizing the package documentation The best I could do was force all columns to the right. It may also depend on your YAML settings. What output are you rendering to? I may have had different results since I am using html_document
with the package you specify your table body style, and then map it inside your ggtexttable()
function.
tbody.style = tbody_style(hjust=1, x=0.9)
This is my reproducible solution
---
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))
```
Upvotes: 0