I want to make one figure in R with two graphs in a markdown file with knitr. This is usually easy to do with layout(t(1:2))or par(mfrow=c(1,2)). Can I do this with knitror will always do two separate digits?
Here is a minimal working example that creates a file with the name ./junk.Rmdand ./junk.mdin your working directory along with two files ./figure/junkislands1.png(which includes only the first graph) and ./figure/junkislands2.png(which includes both the graphs that I want).
require(knitr)
temp <- "```{r junkislands, fig.width=8, fig.height=5}
layout(t(1:2))
pie(islands)
barplot(islands)
```"
cat(temp, file="junk.Rmd")
knit("junk.Rmd", "junk.md")
The problem is not so much that it creates two .png files, but that the markdown file junk.mdincludes both of them.
When I make this markdown in html, it includes both .png files, when I need only the one that has both figures.
junk.md, knitr:
```r
par(mfrow = c(1, 2))
pie(islands)
```

```r
barplot(islands)
```
