Send an email with a gt table that contains images as rows

172 views Asked by At

I'd like to send an email using blastula and Microsoft365R with a gt table inside. But I've stumbled on the following situation:

library(Microsoft365R)
library(gt)
library(blastula)

# From: https://gt.rstudio.com/reference/local_image.html

dplyr::tibble(
  pixels = px(seq(10, 35, 5)),
  image = seq(10, 35, 5)
) |>
  gt() |>
  tab_header(
    title = "A1",
    subtitle = "A2"
  ) |> 
  text_transform(
    locations = cells_body(columns = image),
    fn = function(x) {
      local_image(
        filename = test_image(type = "png"),
        height = as.numeric(x)
      )
    }
  ) |> 
  as_raw_html() -> prueba

correo_gnrl <- get_business_outlook()
mail_temp <- compose_email(md(prueba))
correo_gnrl$create_email(mail_temp,
                         to = "[email protected]",
                         send_now = TRUE)

This results in the following:

enter image description here

Which means I have no way of resizing the image. I'd like to have control of the size of the images to go onto the table so that it looks appropiate.

Thanks in advance.

> sessionInfo()
R version 4.3.2 (2023-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)

Matrix products: default


locale:
[1] LC_COLLATE=Spanish_Peru.utf8  LC_CTYPE=Spanish_Peru.utf8    LC_MONETARY=Spanish_Peru.utf8
[4] LC_NUMERIC=C                  LC_TIME=Spanish_Peru.utf8    

time zone: America/Lima
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] blastula_0.3.4      gt_0.10.1           Microsoft365R_2.4.0

loaded via a namespace (and not attached):
 [1] jsonlite_1.8.8    dplyr_1.1.4       compiler_4.3.2    tidyselect_1.2.0  Rcpp_1.0.11      
 [6] xml2_1.3.6        stringr_1.5.1     fastmap_1.1.1     mime_0.12         R6_2.5.1         
[11] commonmark_1.9.0  generics_0.1.3    curl_5.2.0        tibble_3.2.1      pillar_1.9.0     
[16] rlang_1.1.2       utf8_1.2.4        V8_4.4.1          stringi_1.8.3     fs_1.6.3         
[21] sass_0.4.8        juicyjuice_0.1.0  cli_3.6.2         withr_3.0.0       magrittr_2.0.3   
[26] digest_0.6.33     rstudioapi_0.15.0 base64enc_0.1-3   rappdirs_0.3.3    AzureAuth_1.3.3  
[31] lifecycle_1.0.4   vctrs_0.6.5       AzureGraph_1.3.4  glue_1.6.2        fansi_1.0.6      
[36] httr_1.4.7        tools_4.3.2       pkgconfig_2.0.3   htmltools_0.5.7  



RStudio.Version()$version
[1] ‘2022.12.0.353’

0

There are 0 answers