Questions tagged [gtextras]

10 questions
5
votes
1 answer

Combine multiple gt tables to single one plot

With code below (edited basing on code from here) I generates two example tables with gt package: library(tidyverse) library(patchwork) library(gt) p1 <- mtcars %>% head(5) %>% gt() p2 <- mtcars %>% tail(5) %>% gt() # using wrap…
ah bon
  • 9,293
  • 12
  • 65
  • 148
2
votes
1 answer

gtExtras::gt_sparkline to plot multiple columns with NAs without using na.omit()

Based on question from this this link: df1 <- structure(list(type = c("v1", "v2"), `2017-06` = c(300, 100 ), `2017-07` = c(10, 900), `2017-08` = c(500, 700 ), `2017-09` = c(100, 650), `2017-10` = c(850, 600 )), class = "data.frame", row.names =…
ah bon
  • 9,293
  • 12
  • 65
  • 148
1
vote
1 answer

gtExtras winloss table in loop rendering with partially raw, partially rendered HTML

I am trying to print gtExtras::gt_plt_winloss tables in a for loop in a paged HTML RMarkdown document. Outside of a loop, the tables are rendering as expected. Inside of a loop, the table preview is as expected in the console but prints to PDF…
cxinya
  • 25
  • 4
1
vote
1 answer

{gtExtras} column showing in wrong order in {gt} table when grouped

I am making a gt table showing the progress of individuals towards a goal. In the table, there is a row showing a horizontal bar graph of progress towards that goal (if goal is 50 and score is 40, the bar is at 80%). However, when I change the order…
Jake L
  • 987
  • 9
  • 21
1
vote
1 answer

How to make gt_sparkline() coordinate with case one row with all NAs

For the following df, if none of type with all NA or NA_real_, the following code works: library(gt) library(gtExtras) df <- structure( list( type = c("v1", "v2", 'v3'), `2017-06` = c(300, 100, NA_real_), `2017-07` = c(10, 900,…
ah bon
  • 9,293
  • 12
  • 65
  • 148
1
vote
1 answer

Set background colors for the cells of multiple columns based on string contents using gt package

Given a small dataset as follows: library(gt) library(tidyverse) id <- c(1,2,3,4,5) res1 <- c("true", "true", "false", "true", "false") res2 <- c("false", NA, NA, "true", "true") df <- data.frame(id, res1, res2) df %>% gt() Out: For columns…
ah bon
  • 9,293
  • 12
  • 65
  • 148
1
vote
2 answers

Apply gtExtras::gt_sparkline to multiple columns

Based on example code for sparkline from this link: library(gt) library(gtExtras) mtcars %>% dplyr::group_by(cyl) %>% # must end up with list of data for each row in the input dataframe dplyr::summarize(mpg_data = list(mpg), .groups =…
ah bon
  • 9,293
  • 12
  • 65
  • 148
0
votes
0 answers

Rendering sparklines in LaTeX in R Markdown using gtExtras

This code from gtExtras website: library(gt) gt_sparkline_tab <- mtcars %>% dplyr::group_by(cyl) %>% # must end up with list of data for each row in the input dataframe dplyr::summarize(mpg_data = list(mpg), .groups = "drop") %>% …
R Walser
  • 330
  • 3
  • 16
0
votes
0 answers

Use gt_hyperlink from gtExtras to add link to gt table

How do I use gt_hyperlink from {gtExtras} to add a link to a cell in a gt table? In this example, the words, "This is CNN", would link to cnn.com library("tidyverse") library("gt") library("gtExtras") df <- tibble( name = "This is CNN" ) df |>…
ixodid
  • 2,180
  • 1
  • 19
  • 46
0
votes
1 answer

How to manually set the color of sparkline lines and extrema in gt_plt_sparkline() of gtExtras 0.4.3

On gtExtras 0.3.8, we can set the color of sparkline lines and extrema by parameters line_color = 'grey', range_colors = c('blue', 'red') (refer to gt_sparkline()) When gtExtras is upgraded to version 0.4.3, we need to execute the following code to…
ah bon
  • 9,293
  • 12
  • 65
  • 148