抑制函数的输出 [英] Suppress output of a function

查看:67
本文介绍了抑制函数的输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望抑制 one 命令的输出(在本例中为 apply 函数).

I'm looking to suppress the output of one command (in this case, the apply function).

是否可以在不使用 sink() 的情况下做到这一点?我找到了下面描述的解决方案,但如果可能的话,我想在一行中执行此操作.

Is it possible to do this without using sink()? I've found the described solution below, but would like to do this in one line if possible.

如何抑制输出

推荐答案

不清楚为什么要在没有 sink 的情况下执行此操作,但是您可以将任何命令包装在 invisible() 函数,它将抑制输出.例如:

It isn't clear why you want to do this without sink, but you can wrap any commands in the invisible() function and it will suppress the output. For instance:

1:10 # prints output
invisible(1:10) # hides it

否则,您始终可以使用分号和括号将内容合并为一行:

Otherwise, you can always combine things into one line with a semicolon and parentheses:

{ sink("/dev/null"); ....; sink(); }

这篇关于抑制函数的输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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