可能重复:
R抑制依赖项的启动消息
我已经了解到使用sink("NUL")
/sink("/dev/null")
,但它们都没有解决我遇到的问题。即使我将library()
命令包装在sink("NUL")
和sink()
中,我的Rscript调用仍然输出各种我不想看到的信息:
Loading required package: Matrix
Loading required package: methods
Loading required package: lattice
Loaded glmnet 1.8
Loading required package: MASS
Loading required package: lme4
Attaching package: 'lme4'
The following object(s) are masked from 'package:stats':
AIC, BIC
Loading required package: R2WinBUGS
Loading required package: coda
Attaching package: 'coda'
The following object(s) are masked from 'package:lme4':
HPDinterval
Loading required package: abind
Loading required package: foreign
arm (Version 1.5-05, built: 2012-6-6)
Working directory is C:/Users/andrews/bootstraps/user/_branches/ER-PoC/Bootstraps/R
Attaching package: 'arm'
The following object(s) are masked from 'package:coda':
traceplot
[1] "client=51" "date='01-01-2011'"
[1] "01-01-2011"
[1] 51
我实际上只需要结尾的内容,也似乎只有使用sink()
命令才能抑制输出。真的感觉应该有一个参数可以在Rscript
中抑制此输出(如果我在控制台中source
我的脚本,则甚至不会显示此输出)...有任何建议吗?
?suppressPackageStartupMessages
可以帮助吗? - ChasesuppressMessages()
按照OP所述并不完全抑制输出。因此,“完全相同”的标记对这个用户没有帮助。 - Thell