Questions tagged [gt]

Use this tag for questions related to the gt package. The gt package provides functions to make it easy to create and style tables in the R programming language.

The package provides functions to make it easy to create and style tables in the programming language. Like the grammar of graphics for data visualization (see ), the philosophy behind is to provide a grammar of tables.

An overview and introduction to the package can be found on the package website.

429 questions
4
votes
2 answers

Way to format gt table across a single row?

I'm trying to format my gt table with conditions and am at a bit of a standstill. Most of the examples I'm finding are formatting based off of column headers. Here's the code for an example table with the first column named "row" w/ values 1-6. How…
Xal
  • 55
  • 4
4
votes
0 answers

Scale down gt table for R Markdown PDF

This is a very general question. I created a few tables in an R markdown using the gt package. I was wondering how to scale down the table so it fits into the PDF created when I knit the markdown script. I have the following code for the table: DEGs…
dengel1392
  • 53
  • 7
4
votes
1 answer

Saving gt table as PNG without phantomjs

I have gt tables I would like to save as PNGs. I tried doing webshot but since I'm using a work secured desktop I don't have the authorization to download phantomJS. I can still click export as image on RStudio viewer, but I would like to do it in…
cat_jesus
  • 41
  • 2
4
votes
1 answer

To get a huxtable in 2 pages in PDF type RMD

I have a huxtable to be printed which is at the end of the first page. Due to its size and width, the huxtable gets printed on the second page. Is there any possible way where I can split the portion of the table and project the first half of the…
Sai Anand
  • 67
  • 6
3
votes
2 answers

Automatically prefix row group names of a `gt` table

I have the following gt table that has two groups: library(gt) library(dplyr, warn.conflicts = FALSE) iris[c(1:2, 51:52), ] |> group_by(Species) |> gt() I'd like to prefix the title of each group with "Panel XX" where "XX" is the group…
bretauv
  • 7,756
  • 2
  • 20
  • 57
3
votes
2 answers

LaTeX in column names of a table in R markdown

How can I have LaTeX symbols like alpha or delta in column names of html output with gt package. library(gt) # Create a data frame data <- data.frame( x = c(1, 2, 3), y = c(4, 5, 6) ) # Set the column names as LaTeX formulas colnames(data) <-…
Marco
  • 2,368
  • 6
  • 22
  • 48
3
votes
2 answers

How do I display gt tables created in a loop in RMarkdown Word output?

I'm having trouble getting RMakrdown to display gt tables in Word output when the tables are created inside a loop. Straightforward use of gt with Word output works as expected: --- title: "Testing gt" output: word_document: default --- ```{r,…
user862507
  • 65
  • 5
3
votes
1 answer

Change row group labels in gt table (with superscript/subscript and line breaks). Customising row group labels in R

I have the following data and table: library(gt) library(dplyr) a <- rnorm(21, mean = 112, sd =12) colour <- rep(c("Blue", "Red", "Green"), 7) data <- data.frame(colour, a) %>% group_by(colour) %>% summarise(mean = mean(a), sd = sd(a), n =…
MM1
  • 478
  • 15
3
votes
1 answer

Choose different types of footnote marks in different columns in a gt table

I want to change the footnote marks in my gt table so that in the wt column, I do not have the number 2 but an asterisk (*). I want to keep footnote mark 1. library(gt) # Create a sample gt table with custom footnote marks my_table <- gt( …
LDT
  • 2,856
  • 2
  • 15
  • 32
3
votes
2 answers

why defining only __lt__ makes > operation possible?

class Node: def __init__(self,a,b): self._a=a self._b=b def __lt__(self,other): return self._ab) The code above shows True. class Node: def __init__(self,a,b): …
3
votes
2 answers

Is it possible to have footnotes after source in gt table?

I have the following table: datasets::mtcars %>% head(5) %>% gt() %>% tab_footnote("Footnote: Go Below", locations = cells_body(columns = mpg, rows = c(2))) %>% …
RL_Pug
  • 697
  • 7
  • 30
3
votes
1 answer

How do I colour every other category with gt()?

library(gt) library(dplyr) data <- 1:150 %>% sample(10) %>% iris[.,] data Sepal.Length Sepal.Width Petal.Length Petal.Width Species 68 5.8 2.7 4.1 1.0 versicolor 102 5.8 2.7 5.1 …
Dave4048
  • 173
  • 10
3
votes
1 answer

How to remove one row of column labels in a gt table?

#Preparing the data and loading packages library(modelsummary);library(tidyverse);library(gt) as_tibble(mtcars) df <- mtcars %>% mutate(cyl_ = factor(cyl)) %>% dplyr::select(cyl_, mpg, vs, am, hp, wt) #Gets table of descriptive statistics about…
tci
  • 69
  • 7
3
votes
2 answers

How to rotate the column headers with R package gt?

Is there a way to rotate by 90 degrees the column headers with the gt package and make them vertical? Thanks in advance!
andreranza
  • 93
  • 6
3
votes
1 answer

Add Group Subheader and Subtotal Rows to data.frame or table in R

Objective I wish to add subheader and subtotal/margin rows within a table. Ultimately, I am looking for a structure shown below, which I will export to Excel with openxlsx and…
AWaddington
  • 725
  • 8
  • 18
1 2
3
28 29