Saving Reports Generated in R to Evernote

Evernote is my digital filing cabinet. I keep lots of information in it because it is backed up, easy to find and with me wherever I am on all my devices. It is not surprising therefore that I frequently want to store analysis that I carry out in R as an Evernote note.
To produce reports I prefer to use the spin function in Knitr. I love spin because you don’t need a separate markdown file. You can still run the entire script if you want to, because all the markdown formatting instructions just look like comments to regular R. More information on the advantages of spin vs regular markdown here.
Evernote (at least on Windows, I don’t know about other systems) has a wonderful device called an import folder. Any files added to this folder are automatically added to Evernote. In most cases the file is simply attached to a new note. However in the case of html, txt and rtf files, the contents of the file is added to the body of a new note and the file is not attached.  Initially I thought that saving my html document produced by spin to the Evernote import folder would be all I would need to do. Sadly it wasn’t straightforward because it seems that the import folder doesn’t play nicely with local html files –  the more advanced formatting produced by spin is destroyed and images are sometimes not included.
After some experimentation my preferred option (option 6 in the table below) is as follows:
1. Save the output of spin as an html file to Dropbox.
2. Go to Dropbox on the web and open the document (ctrl clicking opens it in a new window without Dropbox clutter). It looks like a regular html web page.
3. Use the Evernote webclipper to save the file to Evernote
Although this is not ideal because there are still some manual steps, it is the only way I could find of achieving goals 1 and 3 in the table below and being able to at least semi-automate the process.
The very short script required to produce the file and take you to Dropbox is as follows, where the R script file referred to (spinexample.R) reproduced below is a properly formatted spin script see here for details . You will need to wait for a few seconds for Dropbox to upload the file to the web before you can see it.
Script that produces report:
opts_chunk$set(warning=FALSE,  results = "markup",
              out.width = "100%", echo = TRUE)
              output_dir = "C:/Users/Mike/Dropbox/R2EN")

The report script (spinexample.R)

#' ---
#' title: "Spin to Evernote Example"
#' author: "Mike"
#' ---
x <- rnorm(1000)
#' Here is the mean. **It's a very important number.**
#' Here is a pretty histogram
#+ echo=FALSE
#' This is the summary of the random numbers
#' Here is a sum

For reference here is a brief summary of the different approaches I tried. Note that none of these have a full line of crosses. An Evernote note showing the results for options 3, 4 and 6 can be accessed here

Goal 1 – Advanced formatting (highlighted code etc)
Goal 2 – Completely Automatic
Goal 3 – Content forms the body of the note
Manually copying and pasting output into Evernote
Use spin to save an html file to the Evernote import folder
html must not be self contained (otherwise it leaves out any images)
Use spin to save a Word document or pdf document to the Evernote import folder
Use spin to save a rtf document to the Evernote import folder
Because the the render to rtf doesn’t support advanced formatting anyway you actually see in EN what you get in the rtf document
Render as html. Copy and paste content into a gmail. Either webclip or send to Evernote
Preferred option
Use spin to save an html file to Dropbox and then use the webclipper

One thought on “Saving Reports Generated in R to Evernote

  1. Oh well all good things come to an end. As of mid July 2017 Dropbox have disabled the ctrl-click trick to render the html without clutter. The page with clutter does not work with the webclipper. So it’s the gmail option above or set up a website.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s