I'm trying to find a way to loop through rows of a data frame to produce a report (preferably in PDF) that includes strings the length of a paragraph or longer, plots, and data values for each day of the year. I've exported PDFs of just plots in a loop before, but I can't find a solution to include text of any considerable length.
Imagine I have a data frame like this:
Date <- c("01/01/2014", "01/02/2014", "01/03/2014")
TextString <- c("imagine this is a paragraph or longer 1", "imagine this is a paragraph or longer 2", "imagine this is a paragraph or longer 3")
TableData1 <- c(10000, 9000, 8000)
TableData2 <- c(6, 5, 4)
PlotData3 <- c(22, 11, 21)
PlotData4 <- c(6, 7, 8)
PlotData5 <- c(21, 17, 14)
Report <- data.frame(Date, TextString, TableData1, TableData2, PlotData3, PlotData4, PlotData5)
And I would like the report to be structured something like this in the PDF:
01/01/2014
imagine this is a paragraph or longer 1
"TableData1:" 10000
"TableData2:" 6
*plot* pie(c(Report$PlotData3[1], Report$PlotData4[1], Report$PlotData5[1]))
01/02/2014
imagine this is a paragraph or longer 2
"TableData1:" 9000
"TableData2:" 5
*plot* pie(c(Report$PlotData3[2], Report$PlotData4[2], Report$PlotData5[2]))
01/03/2014
imagine this is a paragraph or longer 3
"TableData1:" 8000
"TableData2:" 4
*plot* pie(c(Report$PlotData3[3], Report$PlotData4[3], Report$PlotData5[3]))
Can anyone point me in the right direction? I looked at some tutorials for knitr since it seems applicable, but I wasn't sure it would loop through data in this manner.