如何使连接操作沉默? [英] How to make join operations in dplyr silent?

查看:136
本文介绍了如何使连接操作沉默?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

dplyr(版本0.4.1)打印正在执行连接的colnames。可以关闭此选项吗?

dplyr (version 0.4.1) prints the colnames by which it is performing the join. Is it possible to turn this option off?

R代码:

library(dplyr)
a=data.frame(x=1,y=2)
b=data.frame(x=1,z=10)
aa=inner_join(a,b)

最后一行,dplyr打印:

for the last line, dplyr prints:

Joining by: "x"

对于交互式工作,但是我在Rscript中运行,所有这些行都堵塞了我的屏幕。

that is nice for interactive work, but I am running in Rscript and all these lines are clogging my screen.

推荐答案

如果你想要重你可以做

aa = suppressMessages(inner_join(a, b))

Jazzurro建议的更好的选择是通过参数指定 dplyr 只打印一条消息,让您知道他们猜测哪些列加入。如果你不猜测,它不会与你确认。

The better choice, as Jazzurro suggests, is to specify the by argument. dplyr only prints a message to let you know what its guess is for which columns to join by. If you don't make it guess, it doesn't confirm things with you.

如果这是一个 knitr 文件,你可以设置块选项 message = FALSE

If this is in a knitr document, you can just set the chunk option message=FALSE.

这篇关于如何使连接操作沉默?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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