How do I create multiple HTML files in a single R markdown file with the Knit HTML option in RStudio? I want to create a separate HTML file with graphs for different levels of a variable in a data frame. I know a similar question has been posted in How to best generate multiple HTML files from RMarkdown based on one dataset?, but I do not manage to get this running.
Could someone give me a simple example, for instance to create 3 HTML files of the mtcars dataset for each amount of cylinders.
data(mtcars)
for(cyl in unique(mtcars$cyl)){
plot.data <- mtcars[mtcars$cyl==cyl,]
plot(plot.data$mpg,plot.data$disp,main=paste(cyl,"cylinders"))
}
This would be of great help for me!
Thanks in advance, Gijs