[R-SIG-Finance] Automatically sending .Rmd -> html files

Enrico Schumann enricoschumann at yahoo.de
Tue Jun 12 11:26:33 CEST 2012


Hi,

>
> With all the buzz around R Markdown, has anyone yet experimented with
> getting  R Markdown files to automatically run, convert to html as usual
> and then attach / run in-line on an email and send it?

I wasn't aware of any buzz :-) But seriously, as you mentioned yourself, 
this is not really a finance question. So you may get better answers on 
R-help.

I don't use Markdown; but still, some thoughts/pointers:

(1) To borrow Perl's slogan, there is more than one way to do it. And 
this is definitely the rule here: just find some setup that works for 
you. In the end, you will anyway collect all pieces in a script, ie, a 
batch file on Windows. The Task Scheduler accepts such batch files. (If 
you want complete automation, you will also want to think about 
error-handling: "Hm, you want me to send this file, but it is more than 
24h old.")

I wouldn't expect to do everything in R; there are many 
incredibly-useful tools that can be run from the command line, even on 
Windows (as an example, I use Sweave to automatically create tex-files; 
tex-files could be transformed into HTML via tools like Pandoc).

You may also want to have a look at the CRAN Task View for Reproducible 
Research.

(2) You will run R non-interactively, so have a look at the 
documentation of RScript and R CMD BATCH.

(3) You can send e-mails from the command line on Windows with 
programmes like Blat ( http://www.blat.net/ ). This may also allow you 
to send HTML mails, but I wouldn't know: I only send and read plain-text 
mails, ie, the format that this mailing list expects.


Regards,
Enrico

>
> I think I can put this together with a cron job, but i'd be interested
> in thoughts on running this via task Scheduler on Win 7; so far I've not
> found a way of getting Task Scheduler to associate .Rmd files with R.
>
> Ideally, what I'm trying to achieve is, at a given time of day (say 6am):
>
>    * Launch R
>    * Run `xyz.Rmd`
>    * Take the standard output (`xyz.html') and use in the body of an
>      email (or, at least, have an attachment of the html)
>    * Send the email
>
> Any thoughts very much appreciated. I know this isn't strictly finance,
> but I can imagine the finance community probably has the most amount of
> use for something like this on a daily basis (emailing automated
> analysis to yourself / desk etc)
>
> n.
>

-- 
Enrico Schumann
Lucerne, Switzerland
http://nmof.net



More information about the R-SIG-Finance mailing list