简体   繁体   English

安排邮件R / Knitr报告

[英]Schedule mail R/Knitr reports

I need to schedule some monthly reports that need to be sent by email. 我需要安排一些需要通过电子邮件发送的月度报告。 I love the flexibility of R for analisys and data manipulation and even if not very experienced with knitr I would manage to produce the reports I need. 我喜欢R对于分析和数据操作的灵活性,即使对knitr没有很多经验,我也会设法生成我需要的报告。 My problem is with the mailing bit. 我的问题在于邮寄位。 What would be the best workflow to achieve this? 实现这一目标的最佳工作流程是什么?

I have never done this kind of job but if I have to do, I would not use an R package to send mail. 我从未做过这种工作,但如果必须这样做,我就不会使用R包来发送邮件。 I would use something like Mutt (available on windows also) Mail User Agent to send my report as an attachment. 我会使用类似Mutt在Windows上也可用)Mail User Agent将我的报告作为附件发送。 Do I would create a batch mailsender.(sh|bat) that launch this R script mailsender.R : 我是否会创建一个批量mailsender。(sh | bat)来启动这个R脚本mailsender.R

   source('genreport.R')  ## here you will call for example knit2pdf('myreport.Rnw')
   writeLines(message,p<-pipe('mutt -s mySubject -a myreport.pdf -- mail@mail.com'))
   close(p)

Your batch/shell script contain : 您的批/ shell脚本包含:

  Rscript path_to_mailsender_\mailsender.R

Finally you can use cron or windows scheduler ( I don't know for mac) to schedule monthly this job. 最后你可以使用cronwindows scheduler (我不知道为mac)来安排每月这份工作。

For example using cron , you need somthing like this to send you report at 8pm on the first of every month: 例如,使用cron,您需要这样的事情在每个月的第一天晚上8点向您发送报告:

       0 8 1 * * /path/to/mailsender.sh

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM