How to disable output from this R package?

I play a package a bit LowRankQP()in R, and even the installation verbose=FALSEstill produces many outputs (see example below).

The outputs come from the compiled part of the code. Is there a way (wrap function?) In R to make the call LowRankQP()completely silent (i.e. don't print anything on the screen) without changing the base compiled code (none of the email addresses associated with this package is still active)?

library(LowRankQP)

Vmat <- matrix(0,6,6)
diag(Vmat) <- c(1, 1,1,0,0,0)
dvec <- c(0,-5,0,0,0,0)
Amat <- matrix(c(-4,-3,0,-1,0,0,2,1,0,0,-1,0,0,-2,1,0,0,-1),6,3)
bvec <- c(-8,2,0)
uvec <- c(100,100,100,100,100,100)

aa<-LowRankQP(Vmat,dvec,t(Amat),bvec,uvec,method="CHOL")

# LowRankQP CONVERGED IN 15 ITERATIONS
# 
#     Primal Feasibility    =   2.5719308e-16
#     Dual Feasibility      =   7.1949984e-16
#     Complementarity Value =   3.3066705e-11
#     Duality Gap           =   3.3065273e-11
#     Termination Condition =   9.7802929e-12

This is the part that starts with "LowRankQP CONVERGED IN 15 ITERATIONS", which I want away with.

Ubuntu 11.04, R version 2.12.1 and LowRankQP () 1.0.1.

+5
source share
4 answers

sink (file = NULL) , , .

sink (file = NULL) : ( = NULL):

:

f = file()
sink(file=f) ## silence upcoming output using anonymous file connection
... your code here ...
sink() ## undo silencing
close(f)

, , .. .

:

f = file()
sink(file=f)
example(glm)
sink()
close(f)

sink() (, normalmixEM2comp {mixtools}).

(edit: , , - , ). close (f).

+5

R sink()? :

sink                   package:base                    R Documentation

Send R Output to a File

Description:

     ‘sink’ diverts R output to a connection.

     ‘sink.number()’ reports how many diversions are in use.

     ‘sink.number(type = "message")’ reports the number of the
     connection currently being used for error messages.

Usage:

     sink(file = NULL, append = FALSE, type = c("output", "message"),
          split = FALSE)

     sink.number(type = c("output", "message"))

Arguments:

    file: a writable connection or a character string naming the file
          to write to, orNULLto stop sink-ing.

file=NULL - , .

+2

Well, I could do this by commenting out lines 413-> 418 from LowRankQP.c and reinstalling it from .tar.gz (or, alternatively, adding a new option verbose == 2).

+1
source

I won’t if it works, but you can try invisible(). I don’t know what function you are using, and I don’t know if there is invisible silence cat(). But you could leave.

0
source

All Articles