I am creating a PDF document with with rmarkdown and knitr. Below is an example code chunk. When knitting to PDF it prints the scalebox value to the PDF, which I don't want. My actual table is much wider so using the scalebox argument is necessary.
```{r, results = 'asis', echo = FALSE, message = FALSE, warning=FALSE}
x <- matrix(rnorm(1000), ncol = 10)
x.big <- xtable(x)
print.xtable(x.big, hline.after=c(-1), tabular.environment = "longtable", scalebox = 0.7)
```

This only happens when using the longtable tabular environment. Running the same code chunk with the standard tabular environment doesn't output the scalebox info. I've tried setting every comment argument in the print.xtable function and the r code chunk to FALSE but with no luck.
How can I output my PDF file without that scalebox text being printed?
I haven't found a way to get around the scalebox issue. What I ended up doing was using was the size argument in print.xtable instead. Below is a sample function where size is an integer representing the desired size of the font.
outputXtableTest <- function( df, size){
sizeNew = paste0("\\fontsize{", size,"pt}{", size+1, "pt}\\selectfont")
print.xtable(
df, hline.after=c(-1,0, 1:nrow(table)),
tabular.environment = 'longtable',
floating = FALSE, size = sizeNew
)
}
See this post for more information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With