Faydey
Faydey

Reputation: 737

Print kable table to .tex file

I have a table generated in kable that I want to print to a .tex file, in the same way I would use print.xtable.

that is,

print(xtable(data.frame, xtable.options), print.options, file = filename.tex))

When I tacked print onto a kable table generation, it doesn't work. It seems to be ignored.

I am using:

kable(df, format = 'latex', kable.options) %>% print(file = filename.tex)

Note, the pipe operator %>% should drop the preceding into the first argument of the following function. I do not see a print.kable function available. Is there some other function I am missing?

I am using kable to allow for grouping columns; something xtable by default doesn't appear to allow.

Upvotes: 2

Views: 477

Answers (1)

Ronak Shah
Ronak Shah

Reputation: 388807

You can use cat -

cat(kable(head(mtcars), format = 'latex'), file = 'file.tex')

Upvotes: 3

Related Questions