Question

I want to output latex versions of my tables. I use xtable() to do so, with one major problem. When I try to generate latex tables from within a function that I call (which typically does lots of other things as well), the files get written as zero length! (I run Windows 7 x64, and use R 2.11).

Example:

fnc <- function (my.table) {
    sink(file="paper/tables/output.tex",caption="my caption")
    xtable(my.table)
    sink()
}

When I run the three lines inside the function directly, the file is written correctly. When I call fnc(my.table), the file is written as zero-length.

Why? Thanks!

Was it helpful?

Solution

you need use print in a function:

print(xtable(my.table))
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top