0
votes

I am putting an assignment together in R Markdown to PDF (through Latex) and been using xtable to nicely format my output. The below code generates a small table that I would like to align right in the document and have text wrap around it. Is there a way to achieve this?

summary.table <- xtable(ddply(aircon, ~when, summarise, Mean=mean(hours), StdDev=sd(hours)), caption="Mean and Standard Deviation (in Hours) Before and After Change")
print(summary.table, include.rownames=FALSE)

Given the update regarding using LaTeX to do the wrapping, how could I write this in R Markdown to take advantage of this? I have tried to print inline using r <code> but that didn't work.

1
This is technically possible with LaTeX. tex.stackexchange.com/questions/49300/… - Roman Luštrik

1 Answers

1
votes

I guess you could add the begin/end wraptable commands in the r-chunk that creates the table, like this:

cat("\\begin{wraptable}{r}{5.5cm} \n")
...
print(summary.table,...)
cat("\\end{wraptable} \n")

You can use the Includes mechanism documented here, to include a custom header.tex which would contain usepackages, etc.