1

I'm using R Sweave to output an R document into a LaTeX file through R Studio on a Windows 7. I have a very large data frame from which I have to put a sample at the begin of my document. I use xtable for all my other tables after this one, but for this one I've got the problem that with more than 30 variables (columns), I don't have the place to put it on the whole page, even on landscape, without having to break it. Because I tought impossible to use xtable (or a similar way, longtable is only usefull for the length, not the width, to my aknowledge), I used the pander code to generate a R output, which worked well, except that it isn't the perfect tabular layout I would have wanted (but that's not so dramatic). The problem is that this output spans multiple pages, and I have to put him in a floating environment to make him behave like all other tables in my work (mainly to send him at the end of his section). The goal would really to make him behave like a float, because it could be that I have to make some changes to all floats (like changing their positions) later, and I wouldn't have to ask every time how to find a solution to copy just the little adjustment I made for all the others.

For me it would be splendid to be able to use some xtable-approaching solution, but just inserting my table output onto a float-alike environment would be perfect too.

I join a small reproducible exemple:

\documentclass{book}

\usepackage{caption}
\usepackage{float}
\usepackage[english]{babel}
\usepackage{lipsum}

\begin{document}

<<packages, results=hide, echo=FALSE>>=
library(dplyr)
library(xtable)
library(knitr)
library(pander)
@

Some text before... \lipsum

<<sample_table, echo=FALSE, results=verbatim>>=
iris2 <- sample_n(iris, 32)
orange2 <- sample_n(Orange, 32)
airquality2 <- sample_n(airquality, 32)
dat <- bind_cols(mtcars, iris2, orange2, airquality2, mtcars, iris2)

a <- as.data.frame(dat) %>%
  sample_n(6)

row.names(a) <- NULL
pandoc.table(a, justify="left", missing="-")
@

Some text after... \lipsum

\end{document}

As you can see, the generated table just stays where she appears, and has no floating qualities. That's what I would like to change, either by changing my output method (pander), or by inserting the chunk in some floating environment, without that it cut some part because it needs more than one page to be printed.

I hope my english isn't too bad and the same with my reproducible exemples, if you want that I edit ma question just let me know in the comment and I'll do my best.

Thank you for you help!

nebi
  • 782
GaryDe
  • 111
  • Hi! Welcom to Tex SE. I didn't really understand what you wanted to achieve. You didn't produce a reproducible example. It would make easier to understand and help if you add all the details for a minimal sweave file with YAML and packages (LaTeX+R) used. In that case we don't need the LaTeX output as we could generate it. – nebi Jul 26 '17 at 07:12
  • Thanks for your advice, does it seem better so? – GaryDe Jul 26 '17 at 11:55
  • Much clearer! I understand your problem now, but I don't know how to solve it. There is this answer, but I couldn't find an easy way to implement it... I guess two tables of 15 variables is not an option... – nebi Jul 26 '17 at 15:09
  • Thank you, I've give it a try, but the problem is that I have to change things inside the produced code, what isn't possible (or if it is, I've no idea how). And I don't think that the output would behave like a floating environment, because longtable doesn't float. But thanks for your try :) – GaryDe Jul 27 '17 at 08:55

0 Answers0