title: knitr/rmarkdown - reducing html file size
body: <p>I want to produce an html document using knitr/rmarkdown. Currently, the file is over 20MB and I'm trying to find a way to reduce it. The large file size is probably due to my plots which have a lot of points in them.</p>
  
  <p>If I change my output type to <strong>pdf</strong>, I can get it down to 1.7MB. I'm wondering if there is a way to reduce my file while keeping it as a <strong>html</strong>.</p>
  
  <p><strong>EDIT:</strong> Here's a minimal working example which I did in RStduio.</p>
  
  <pre><code>---
  title: "Untitled"
  author: "My Name"
  date: "September 7, 2015"
  output: html_document
  ---
  
  ```{r}
  library(ggplot2)
  knitr::opts_chunk$set(dev='svg')
  ```
  
  ```{r}
  set.seed(1)
  mydf &lt;- data.frame(x=rnorm(2e4),y=rnorm(2e4))
  ggplot(mydf, aes(x,y)) + geom_point(alpha=0.6)
  ```
  </code></pre>
  
  <p>I also noticed that if I have too many observations, the plot doesn't get generated at all. I just get an empty box with a question mark in the output.</p>
  
  <pre><code>```{r}
  set.seed(2)
  mydf &lt;- data.frame(x=rnorm(5e4),y=rnorm(5e4))
  ggplot(mydf, aes(x,y)) + geom_point(alpha=0.6)
  # ...plot doesn't appear in output
  </code></pre>
  
  <p>```</p>