I'm trying to get my head around using R to generate reports and think I have settled on trying to just use pander, after confusing myself with various combinations of knitr, Rmarkdown, pander and reports.
I now have two files:
'ReportIntro.brew' that contains the structure of the report
# My Report Title
## Sample Information
#### <%=set.alignment('left') ; as.character(info[1,1])%>
<%=set.alignment('left') ; info[2:8,1:2]%>
'Report.R' to create a data.frame 'info' required for the report
library(pander) ; library(xlsx)
info=read.xlsx(file="info.xlsx", sheetName="info", header=FALSE)
Pandoc.brew(file="ReportIntro.brew", output=tempfile(), convert="docx")
This gives me my first Word document, with a table. However, it includes unwanted row and column names. I found a blog about generating tables with pander and knitr, which suggested setting
row.names(info) <- NULL
but this had no effect.
If I try using
print(info[2:8,1:2], include.rownames=FALSE)
or
print(xtable(info[2:8,1:2]), type="html", include.rownames=FALSE)
as suggested in another post about removing row names using xtable, the table doesn't appear at all in the Word doc.
So: how do I get my table without showing row names?
(This is my first post, so I hope it fits the requirements!)
EDIT: This it the result of dput(info)
> dput(info)
structure(list(X1 = c("School Information", "Name", "Type", "DfE number",
"URN", "DfE link", "Dashboard Report", "Ofsted link", "Test Information",
"Test Date", "Comments", "Analysis comments", "Sample Size",
"Year group", "All", "11", "11"), X2 = c(NA, NA, "Primary, Academy, Prep, Middle etc",
NA, "Enter school URN here", "http://www.education.gov.uk/",
"http://dashboard.ofsted.gov.uk/", "http://www.ofsted.gov.uk",
NA, NA, NA, NA, NA, "Set", "All", "top", "middle"), X3 = c(NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, "M", "408", "165",
"243"), X4 = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, "F", "402", "145", "257"), X5 = c(NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, "Total", "810", "310", "500")), .Names = c("X1",
"X2", "X3", "X4", "X5"), row.names = c(NA, 17L), class = "data.frame")