title: How can I embed a plot within a RMarkdown table?
body: <p>I am trying to generate a report template in RMarkdown. In this report, I would like a plot in the cell next to the number and text of a question on the survey that I am using. I generated some example plots and made the following example in MS Word. Is it possible to put an R-generated plot in a table in RMarkdown?</p>
  
  <p>What would the code look like if it is?</p>
  
  <p><a href="https://i.stack.imgur.com/bBM3D.png" rel="noreferrer"><img src="https://i.stack.imgur.com/bBM3D.png" alt="Desired output"></a></p>
  
  <p><em>Edit (9/8/16):</em> I am including the .Rmd file as it stands now. The issue is that the html file fails to compile with the following message. </p>
  
  <pre><code>pandoc: Could not fetch Template1_files/figure-html/score_table-1.png
  Template1_files/figure-html/score_table-1.png: openBinaryFile: does not exist (No such file or directory)
  Error: pandoc document conversion failed with error 67
  Execution halted
  </code></pre>
  
  <p>Template1 is the file name, score_table is the chunk label.</p>
  
  <p>Would someone be willing to help me diagnose the problem?</p>
  
  <pre><code>&lt;meta charset="utf-8"&gt;
  ---
  title: "Untitled"
  author: "Xander"
  date: "September 7, 2016"
  output: html_document
      self_contained: false
  ---
  
  ```{r mychunk, fig.show = "hide", echo = FALSE, fig.height=3, fig.width=5}
  library(knitr)
  library(ggplot2)
  
  # sample data
  dat &lt;- data.frame(text = sapply(1:10, FUN = function(x) { paste0(sample(x = LETTERS, size = 15), collapse = "") }))
  score_set = replicate(n = 10, expr = {data.frame(other = c("other", "other", "other", "other"), score=sample(1:7,4,TRUE))},simplify = F)
  
  #Plot Function
  plotgen&lt;-function(score_set,other,score){
    p &lt;- ggplot(score_set, aes(factor(other), score))
    p + geom_violin(fill = "#99CCFF") + coord_flip() + scale_x_discrete(name=NULL) +
    scale_y_continuous(breaks = round(seq(1, 7, by = 1),1), limits = c(1,7), name=NULL) + theme(axis.text.y=element_blank(),axis.title.y=element_blank(),axis.ticks.y=element_blank(),
        panel.grid.major.y = element_line(colour = "black"),
        panel.grid.minor = element_blank(),
        panel.background = element_rect(fill = "white"),
        panel.border = element_rect(colour = "black", fill=NA, size=1)) +
  geom_hline(yintercept=sample(1:7,1,TRUE), size = 1.5, colour = "#334466")
  }
  
  # generate plots
  invisible(lapply(seq_along(score_set), FUN = function(x) {plotgen(score_set[[x]],other,score)}))
  
  out &lt;- cbind(row.names(dat), 
           as.character(dat$text), 
           sprintf("![](%s%s-%s.png)", opts_current$get("fig.path"), opts_current$get("label"), 1:nrow(dat)))
  kable(out, col.names = c("ID", "Text", ""))
  ````
  </code></pre>