Search code examples
rcomponentssna

How to Hide Output From sna::components?


I try running

library(sna)
g <- rgraph(100, tprob=0.1)
cmp <- invisible(components(g))

And it still prints output. I want no output.

Node 1, Reach 100, Total 100
Node 2, Reach 100, Total 200
Node 3, Reach 100, Total 300
Node 4, Reach 100, Total 400
Node 5, Reach 100, Total 500
Node 6, Reach 100, Total 600
Node 7, Reach 100, Total 700
...

I've tried setting options like options(verbose=F), but this doesn't work either.

Perhaps it's related to this answer? I am using RMarkdown eventually.


Solution

  • You should be able to suppress the output with:

    X <- capture.output(cmp <-components(g))