# NOT RUN {
# Get the PNG-based logo for the R
# Project from an image URL
r_png_url <-
"https://www.r-project.org/logo/Rlogo.png"
# Create a tibble that contains heights
# of an image in pixels (one column as a
# string, the other as numerical values),
# then, create a gt table; use the
# `text_transform()` function to insert
# the R logo PNG image with the various
# sizes
tab_1 <-
dplyr::tibble(
pixels = px(seq(10, 35, 5)),
image = seq(10, 35, 5)
) %>%
gt() %>%
text_transform(
locations = cells_body(vars(image)),
fn = function(x) {
web_image(
url = r_png_url,
height = as.numeric(x)
)
}
)
# Get the SVG-based logo for the R
# Project from an image URL
r_svg_url <-
"https://www.r-project.org/logo/Rlogo.svg"
# Create a tibble that contains heights
# of an image in pixels (one column as a
# string, the other as numerical values),
# then, create a gt table; use the
# `tab_header()` function to insert
# the R logo SVG image once in the title
# and five times in the subtitle
tab_2 <-
dplyr::tibble(
pixels = px(seq(10, 35, 5)),
image = seq(10, 35, 5)
) %>%
gt() %>%
tab_header(
title = html(
"<strong>R Logo</strong>",
web_image(
url = r_svg_url,
height = px(50)
)
),
subtitle = html(
web_image(
url = r_svg_url,
height = px(12)
) %>%
rep(5)
)
)
# }
Run the code above in your browser using DataLab