I'm trying to embed R lot output inside the cells of an html table. This is as far as I've got:
app.R
require(shiny)
require(knitr)
require(ggplot2)
d = iris
ui = fluidPage(
uiOutput('markdown')
)
server = function(input, output, session) {
output$markdown <- renderUI({
HTML(knit(text = paste(readLines('table.html'), collapse='\n')))
})
}
shinyApp(ui, server)
table.html
<table class='table'>
<tr> <th>text field</th> <th>sparkline</th> </tr>
<tr>
<td>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</td>
<td>
```{r, echo=FALSE, include=TRUE}
# message("setosa") # uncomment to test console output
qplot(Sepal.Length, Sepal.Width, data = d[d == "setosa",], geom="line")
```
</td>
</tr>
<tr>
<td>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.</td>
<td>
```{r, echo=FALSE, include=TRUE}
# message("versicolor")
qplot(Sepal.Length, Sepal.Width, data = d[d == "versicolor",], geom="line")
```
</td>
</tr>
<tr>
<td>Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem.</td>
<td>
```{r, echo=FALSE, include=TRUE}
# message("virginica")
qplot(Sepal.Length, Sepal.Width, data = d[d == "virginica",], geom="line")
```
</td>
</tr>
</table>
knit is outputting the graphics to file. Is there a way to get them to render directly instead? I may be going about this wrong but have not identified an equivalent {rmarkdown} workflow..
As a related point when testing with the message(...) output instead of qplot the html table cell looks like this:
``` ## setosa ```
Any idea how to remove the backticks and hash symbols?

