我有一个名为raw
的数据框,其中大多数列的类型为character
,我想检查一下数据清理。我决定将每列的唯一值作为列表发送到这样的临时文本文件中,
if (interactive()) {
tmp <- tempfile(fileext = '.txt')
sink(file = tmp)
lapply(raw, unique)
sink()
file.show(tmp)
}
当我运行此代码 en bloc 时,文本文件未写入(空白),但是如果我逐步执行这些行,则会得到想要的结果。
我考虑过使用Sys.sleep()
引入某种延迟,但这没有用。我还仔细阅读了sink()
的文档,但找不到与此行为有关的任何内容。
预先感谢您的帮助。