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!
you need use print in a function:
print(xtable(my.table))