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
0
votes
1 answer

Calendar Heatmap in R

Looking to create a gt/reactable table in R that serves as a calendar heatmap. Something just like the one found on this site https://glin.github.io/reactable/articles/cookbook/cookbook.html. When I try to replicate that code, I get an error: "only…
bodega18
  • 596
  • 2
  • 13
0
votes
0 answers

Cross-column summary after `summary_rows` with gt

This is a toy example, so the numbers are meaningless, but how would I calculate the summary statistics for proportion in the summary_rows row of the table per group? proportion is a row-wise calculation, so I can't sum/mean/sd/etc. For average…
Nigel Stackhouse
  • 481
  • 4
  • 20
0
votes
0 answers

Group or Pack Rows with kableExtra for Multiple Tables

I'm a fairly new coder and would appreciate some help. I'm trying to create a report in Rmarkdown that includes tables with a lot of rows and which will therefore need to appear on multiple pages. I first tried to do this using the gt() command…
mbsteel
  • 1
  • 1
0
votes
3 answers

Display class of variables in a nice neat table in R-markdown using gt or gtsummary

I would like to display a dataframe structure nicely, especially showing column names and class. I want to do something kind of like this: str(my_df) %>% tbl_summary() I know that doesn't work, but I thought it would explain what I wanted to do…
Harley
  • 1,305
  • 1
  • 13
  • 28
0
votes
1 answer

XSS source & lt & gt is it correct?

I found the code for XSS. private String cleanXSS(String value) { value = value.replaceAll("<", "& lt;").replaceAll(">", "& gt;"); value = value.replaceAll("\\(", "& #40;").replaceAll("\\)", "& #41;"); value =…
devSimba
  • 11
  • 1
0
votes
2 answers

How to create a blocked hanging indent report format in R (preferably using gt)

I want to report data in R using the display format like an MS Access block grouped report, that is, where the data that is duplicated on the subsequent lines of a group is omitted. library(gt) library(tidyverse) df = tribble( ~a, ~b, ~c, …
Dennis
  • 332
  • 1
  • 4
  • 12
0
votes
1 answer

how to add line break or newline for space in specific columns using kable extra r-markdown?

I'm using r-markdown to generate pdf. i want to add a line break or newline to a column in a dataframe where ever the space is there C1 C2 ID ----------------- 22.6 a-b a 23.5 ba-cd b 24 c-d c 25.3 d-e d i want…
K K
  • 77
  • 7
0
votes
0 answers

Left align table caption

I added a caption to a table. Now, to align the title of the table you can use opt_align_table_header(data, align = c("left", "center", "right")). Is such a function also available for a caption? # Download package …
Ed_Gravy
  • 1,841
  • 2
  • 11
  • 34
0
votes
2 answers

Add Caption to table

I want to caption the table at the top/bottom of a table. Is there a caption function in the gt package? gt(head(mtcars)) %>% tab_header(title="", subtitle="Table 1: Mtcars with gt.") %>% tab_options(table.width=pct(90), …
Ed_Gravy
  • 1,841
  • 2
  • 11
  • 34
0
votes
1 answer

Different colors for all cells of all columns in dt package

I would like to make a simple table and add different specific background color to different values of all cells (if 0 then color x1, if between 0 and 20 then color x2, if between 21-40 then color x3 etc.). I couldn't find out how this works except…
titeuf
  • 133
  • 1
  • 10
0
votes
1 answer

Using inline to get group size in gtsummary

in gtsummary I would like to use the inline_text to get the number of observations in a category. For example, I would like to get the number and percentage of patients (N = 98) taking Drug A in the following table. Dataframe trial with the package…
ebay
  • 109
  • 1
  • 7
0
votes
1 answer

How maked beautiful tables from table object in R

I want to make a beautiful table from table in R. This is the table created from factor variables: a=factor(sample(1:4, 10000, replace=TRUE)) b=factor(sample(c(0,1,NA), 10000, replace=TRUE)) table(a,b,exclude=NULL) This is the output from table…
0
votes
1 answer

How to create a calculated column in R

Below is the sample data set and the desired manipulations. As of yet, all works fine. Attempting to create a new calculated column. Some context, the smb stands for small business. 1,2,3,4 represent differing thresholds of what would be considered…
Tim Wilcox
  • 1,275
  • 2
  • 19
  • 43
0
votes
1 answer

How to produce separate GT tables based on a variable

First is the sample data, schema for one of the variables, and the code that I am using to manipulate it. along with the desired result. I realize upon inspection that the fourth element is not correct and so need clarification on this. The…
Tim Wilcox
  • 1,275
  • 2
  • 19
  • 43
0
votes
0 answers

Bolding Numbers in Data Frame

I have the following dataset (a sample of a large dataset) VARIABLES 1 2 3 4 DEGREE EIGENVECTOR 0.80*** …
Sharif
  • 163
  • 1
  • 9