Dav*_*uer 18 r concatenation paste cat
如果我进入
print(cat(""))
Run Code Online (Sandbox Code Playgroud)
我明白了
NULL
Run Code Online (Sandbox Code Playgroud)
我想用来cat()打印R脚本的进度,但我不明白为什么它会NULL在我所有连接字符串的末尾返回,更重要的是,如何让它停止?
Jos*_*ich 13
您的所有答案都在文档中?cat.回答您特定问题的部分是:
参数:
Run Code Online (Sandbox Code Playgroud)fill: a logical or (positive) numeric controlling how the output is broken into successive lines. If ‘FALSE’ (default), only newlines created explicitly by ‘"\n"’ are printed. Otherwise, the output is broken into lines with print width equal to the option ‘width’ if ‘fill’ is ‘TRUE’, or the value of ‘fill’ if this is numeric. Non-positive ‘fill’ values are ignored, with a warning.
......而且......
值:
Run Code Online (Sandbox Code Playgroud)None (invisible ‘NULL’).
所以你不能停止print(cat(...))回来,NULL因为这是cat回归.你需要明确添加新行cat("foo\n").
我有完全相同的问题.简而言之,cat()在R下有点不知所措.你没有详细介绍你如何使用,cat()但我建议你看看paste().
?paste
我想这可能就是你要找的东西.
我认为不需要使用print(cat()).打印消息 cat()已经足够了.这可能是您正在寻找的:
for (j in 1:n) {
cat("Running loop", j, "of", n, "\n")
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
16312 次 |
| 最近记录: |