Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8346581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T07:04:04+00:00 2026-06-09T07:04:04+00:00

Possible Duplicate: R suppress startupMessages from dependency I’ve read about using sink(NUL) / sink(/dev/null)

  • 0

Possible Duplicate:
R suppress startupMessages from dependency

I’ve read about using sink("NUL") / sink("/dev/null"), but neither of them has fixed the problem I’m having. Even if I wrap the library() commands in sink("NUL") and sink(), my call to Rscript outputs all manner of information I don’t want to see:

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

The stuff at the end is the only output I actually want, and also the only output I seem able to suppress with sink() commands. It really seems like there should just be an argument to Rscript that suppresses this output (which doesn’t even show up if I source my script in the console)… any input?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T07:04:06+00:00Added an answer on June 9, 2026 at 7:04 am

    Andrew, I ran into the same thing and suppressMessages() didn’t remove all the extra output, but using sink() in the form of capture.output() wrapped around the suppressMessages() works.

    $ rscript --vanilla -e 'library(Rmpfr)'
    Loading required package: methods
    Loading required package: gmp
    ---->8----
    Loading C code of R package 'Rmpfr': GMP using 32 bits per limb
    ---->8----
    
    
    $ rscript --vanilla -e 'suppressMessages( library(Rmpfr) )'
    Loading C code of R package 'Rmpfr': GMP using 32 bits per limb
    
    
    $ rscript --vanilla -e 'msg.out <- capture.output( suppressMessages( library(Rmpfr) ) )'
    

    What is going on when loading the Rmpfr package is several well behaved startup messages written using the message connection along with a not so nice message using the output connection. Sure, you could create and manipulate a sink() on your own, but that is what capture.output() is already setup to do.

    Perhaps setting a verbose arg to get a little more control would be helpful::

    $ cat sample.R
    #!/c/opt/R/R-2.15.0/bin/rscript --vanilla
    
    cmd_args <- commandArgs( TRUE );
    
    if( length( cmd_args ) > 0 ) {
      eval( parse( text = cmd_args[1] ) )
    }
    
    if( exists( "verbose" ) ) {
      library( Rmpfr )
    } else {
      msg.trap <- capture.output( suppressMessages( library( Rmpfr ) ) )
    }
    
    print("Hello")
    

    Which yields::

    $ ./sample.R
    [1] "Hello"
    
    
    $ ./sample.R "verbose=TRUE"
    Loading required package: methods
    Loading required package: gmp
    
    Attaching package: 'gmp'
    ---->8----
    [1] "Hello"
    

    Lots of stuff you could play around with there, but at least you can see how to totally suppress the msg output.

    Hope it helps. Have fun!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: git - removing a file from source control (but not from the
Possible Duplicate: Why do I get a null pointer exception from TabWidget? I have
Possible Duplicate: How do you send email from a Java app using Gmail? How
Possible Duplicate: How do I make a request using HTTP basic authentication with PHP
Possible Duplicate: Entity Framework with NOLOCK I'm using EF4 and .Net 4 to load
Possible Duplicate: how to disable javascript errors on “twebbrowser” ? I'm using the TWebBrowser
Possible Duplicate: How to call a JavaScript function from PHP? I have a php
Possible Duplicate: Extracting dollar amounts from existing sql data? I have a column in
Possible Duplicate: Difference of create Index by using include column or not using Edit:
Possible Duplicate: How would I identify if a website originates from a mobile browser?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.