Created
April 8, 2023 10:59
-
-
Save AlbertRapp/17f1c262c34d0e2c6a0b150feed5abc7 to your computer and use it in GitHub Desktop.
dot-columns-gt.R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(gt) | |
circle <- '<span style=" | |
display: inline-block; | |
background-color: pink; | |
width: 1cm; | |
height: 1cm; | |
border-radius: 100%; | |
border: black 1px solid; | |
margin-left: 5px;"> | |
</span>' | |
tibble( | |
grade = c('A', 'B', 'C', 'D', 'F'), | |
students = c(2, 5, 3, 1, 1), | |
plot = map_chr(students, \(x) rep(circle, x) |> paste(collapse = '')) | |
) |> | |
gt() |> | |
fmt_markdown(columns = plot) |> | |
cols_label(grade = 'Grade', students = 'Students', plot = '') |> | |
tab_header(title = 'Fictitious exam results') |> | |
tab_options(heading.align = 'left') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment