在R中,我可以停止print(cat(“”)))返回NULL吗?以及为什么cat(“ foo”)返回foo> [英] in R, can I stop print(cat("")) from returning NULL? and why does cat("foo") return foo>

查看:124
本文介绍了在R中,我可以停止print(cat(“”)))返回NULL吗?以及为什么cat(“ foo”)返回foo>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我输入

print(cat(""))

我得到

NULL

我想使用 cat()打印出进度R脚本,但我不明白为什么它在我所有串联字符串的末尾都返回 NULL ,更重要的是,如何使它停止? p>

I want to use cat() to print out the progress of an R script, but I don't understand why it is returning NULL at the end of all of my concatenated strings, and more importantly, how to get it to stop?

推荐答案

您的所有答案都在?cat 的文档中。回答您特定问题的部分是:

All your answers are in the documentation for ?cat. The portions that answer your specific question are:


参数:



Arguments:

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.


...和...


值:



Value:

 None (invisible ‘NULL’).


所以您不能停止 print (cat(...))返回 NULL ,因为那是 cat 返回的结果。而且您需要显式添加换行符,例如 cat( foo\n)

So you can't stop print(cat(...)) from returning NULL because that's what cat returns. And you need to explicitly add newlines like cat("foo\n").

这篇关于在R中,我可以停止print(cat(“”)))返回NULL吗?以及为什么cat(“ foo”)返回foo>的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆