在生成的电子邮件中打印 R 变量。有更好的方法吗?

Print R variables in generated email. Is there a better way of doing it?

我希望在我的降价完成后生成一封电子邮件,在电子邮件正文中填充信息和一些 ggplots。但是,我 运行 遇到了一些麻烦; R 对象没有打印在 htmlbody 中,因此当我开始添加 ggplots 时,它们也将不起作用。有没有人对我如何让它工作有任何想法?

代码如下(理想情况下 subject_1,subject_2 方法不是我认为我需要的方式):

subject_1 <- "Time Update"
subject_2 <- paste0('(', current_time_round,')')
date <- as.Date(Sys.time())
email_subject <- paste(subject_1, date, subject_2)

OutApp <- COMCreate("Outlook.Application")
Email = OutApp$CreateItem(0)
Email[["to"]] = target
Email[["subject"]] = email_subject

Email[["htmlbody"]] = "<p>Hi Everyone,</p>
<p>Please see attached, and below for the Time update. All data calculated to `r current_time_round`</p>"

Email$Display()

感谢任何 advice/pointers。

编辑:current_time_round 不打印数字。

如此修复:

email_body <- paste("<p>Hi Everyone,</p>
<p>Please see attached, and below for the Time update. All data calculated to", current_time_round,"</p>", )