是否可以通过RDCOM发送可视化图像? [英] Is it possible to send visualizations through RDCOM?

查看:85
本文介绍了是否可以通过RDCOM发送可视化图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对R编程比较陌生,并且做了一个小项目来向R领域自我介绍.我想做的是帮助我的一位同事自动化他每周进行的手动电子邮件处理. /p>

电子邮件包含以excel创建的图表,DOW指数价格,我们公司的股价以及他每周手动更新的一些评论.

我已经弄清楚了如何使用RDCOMClient软件包发送电子邮件,但是我想做的就是将电子邮件的主体(如果可能的话,以HTML格式)集成到图表中,以及他也绘制的股价.我希望将所有这些自动化,因此他要做的就是更新评论并运行脚本.

这里的关键限制因素是目标受众,这将发给真正不喜欢必须打开电子邮件附件的高管.他们想在手机上打开电子邮件,获取相关信息,然后继续前进.

这是到目前为止我的程序的样子:

library(RDCOMClient)
OutApp <- COMCreate("Outlook.Application")
outMail = OutApp$CreateItem(0)
outMail[["To"]] = "test@test.com"
outMail[["subject"]] = "R Test"
outMail[["body"]] = "Hello"                   
outMail$Send()

解决方案

当然,首先保存图像.然后使用HTMLbody通过HTML代码插入图像,如下所示:

library(htmlTable)

png("pictest.png")
plot(iris$Sepal.Length)
dev.off()

StockPrice <- "25.25"

MyHTML <- paste0("<html><p>This is a picture.</p> 
<img src='C:/Users/iwes/Desktop/RWorkingFolder/pictest.png' >
<p> Our StockPrices is: $", StockPrice,
"<p>here is a table:</p>",
htmlTable(head(iris,5)))

library(RDCOMClient)
OutApp <- COMCreate("Outlook.Application")
outMail = OutApp$CreateItem(0)
outMail[["To"]] = "test@test.com"
outMail[["subject"]] = "R Test"
outMail[["HTMLbody"]] =  MyHTML                  
outMail$Send()

I am relatively new to R programming and have undertaken a little side project to introduce myself to the world of R. What I would like to do is help one of my colleagues automate a manual email process that he does each week.

The email consists of a chart created in excel, DOW index prices, our company's stock prices, and some commentary that he manually updates each week.

I have figured out how to use the RDCOMClient package to send emails but what I would like to do is integrate into the body of the email (in HTML format if possible) the charts and stock prices that he also pulls. I am hoping to automate all of this so all he has to do is update commentary and run the script.

The key limiting factor here is the target audience, this will be going out to executives who really do not like having to open email attachments. They want to open an email on their phone, get the relevant information, and move on.

This is what my program looks like so far:

library(RDCOMClient)
OutApp <- COMCreate("Outlook.Application")
outMail = OutApp$CreateItem(0)
outMail[["To"]] = "test@test.com"
outMail[["subject"]] = "R Test"
outMail[["body"]] = "Hello"                   
outMail$Send()

解决方案

Sure, first you save your image. Then use HTMLbody to insert the image using HTML code as follows:

library(htmlTable)

png("pictest.png")
plot(iris$Sepal.Length)
dev.off()

StockPrice <- "25.25"

MyHTML <- paste0("<html><p>This is a picture.</p> 
<img src='C:/Users/iwes/Desktop/RWorkingFolder/pictest.png' >
<p> Our StockPrices is: $", StockPrice,
"<p>here is a table:</p>",
htmlTable(head(iris,5)))

library(RDCOMClient)
OutApp <- COMCreate("Outlook.Application")
outMail = OutApp$CreateItem(0)
outMail[["To"]] = "test@test.com"
outMail[["subject"]] = "R Test"
outMail[["HTMLbody"]] =  MyHTML                  
outMail$Send()

这篇关于是否可以通过RDCOM发送可视化图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆