rmarkdown を使用して作成され、table.rmd ファイルとして保存された、適切にフォーマットされた次のテーブルがあります。
library(RDCOMClient)
kable(mtcars[1:5, 1:6]) %>%
kable_styling(bootstrap_options = c("striped", "hover", "condensed"),
full_width = T,
position = "left",
font_size = 13,
fixed_thead = list(enabled = T, background = "#c5d9f1")) %>%
column_spec(1, bold = T, border_right = T) %>%
column_spec(2, width = "5cm", background = "yellow") %>%
row_spec(4:5, bold = T, color = "white", background = "grey")
ここで、次のコードを使用して、テーブルの元の書式を保持しながら、このファイル/テーブルを Outlook 経由で電子メール本文として送信したいと考えています。
rmarkdown::render("table.Rmd", "html_document")
OutApp <- COMCreate("Outlook.Application")
outMail = OutApp$CreateItem(0)
outMail[["To"]] = "email@abc.com"
outMail[["subject"]] = paste0("Report ", Sys.Date() - 1)
df_html <- read table.html as html so that the df_html gets correctly displayed as well formatted html table.
outMail[["HTMLBody"]] = df_html
outMail$Send()
どうすればいいですか?私の信念は、R で table.html を html 自体として読み取ることができれば、これを行うことができるということです。それで、それが正しければ、outMail[["HTMLBody"]] に割り当てることができる df_html を作成してうまく機能させるにはどうすればよいでしょうか?