R 中的 source() 中的 sink() 无法正常工作

Ber*_*rnd 5 r text-files output sink

我有以下代码:

source("file.R")
Run Code Online (Sandbox Code Playgroud)

文件.R 包括:

tab<-table(variable)
sink("variable.txt")
tab
sink()
Run Code Online (Sandbox Code Playgroud)

但是,variable.txt 文件是空的。知道为什么吗?我在 Mac OS X El Capitan(版本 10.11.6)上使用 RStudio 版本 0.99.902 和 R 版本 3.3.1。

我的一位同事告诉我,这段代码在 Windows 下对他来说运行良好。

任何帮助表示赞赏。此致 !