从函数调用时 xtable 输出的长度为零

发布于 2024-10-01 11:06:10 字数 366 浏览 0 评论 0原文

我想输出我的表格的乳胶版本。我使用 xtable() 来做到这一点,但有一个主要问题。当我尝试从我调用的函数(通常还执行许多其他操作)中生成乳胶表时,文件被写入零长度! (我运行 Windows 7 x64,并使用 R 2.11)。

示例:

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

当我直接运行函数内的三行时,文件被正确写入。当我调用 fnc(my.table) 时,文件被写入零长度。

为什么?谢谢!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风筝有风,海豚有海 2024-10-08 11:06:10

您需要在函数中使用 print :

print(xtable(my.table))

you need use print in a function:

print(xtable(my.table))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文