thermophile
thermophile

Reputation: 153

knitr, suppress nms stress from vegan metaMDS

I want to knitr a report with NMS ordinations. I'd like to include the code in the report but not the Run stress.

I've tried message=FALSE, warning=FALSE, results='hide' but it's still being included in the report.

bc.nms <- metaMDS(as.dist(bc), k=2, trymin=50, trymax=500, wascores=F)

## Run 0 stress 0.2484634 
## Run 1 stress 0.2548965 
## Run 2 stress 0.2660619 
## Run 3 stress 0.2471903 
## ... New best solution
## ... Procrustes: rmse 0.07881697  max resid 0.198888 
## Run 4 stress 0.2515325 
## Run 5 stress 0.2456675 
## ... New best solution
## ... Procrustes: rmse 0.04504745  max resid 0.2189408 
## Run 6 stress 0.2563108  

I want just

bc.nms <- metaMDS(as.dist(bc), k=2, trymin=50, trymax=500, wascores=F)

If it helps figure out how to suppress the unwanted results, here is my knitr options and a screen shot of my report

output: html_document: toc: true # table of content true depth: 3 # upto three depths of headings (specified by #, ## and ###) self_contained: yes

enter image description here

UPDATE. sorry should have included using the vegan dataset instead.

install.packages("vegan")
library(vegan)
data(dune)
bc.nms <- metaMDS(dune, k=2, trymin=50, trymax=500)

the solution within vegan is more direct than capture.output (which also works)

bc.nms <- metaMDS(dune, k=2, trymin=50, trymax=500, trace=FALSE)

Upvotes: 5

Views: 433

Answers (1)

J.Con
J.Con

Reputation: 4309

Based on this answer, you can try:

capture.output(bc.nms <- metaMDS(as.dist(mtcars), k=2, trymin=50, trymax=500, wascores=F), file='NUL')

I get warnings as I am just using the mtcars dataset, not sure if you do but you can use options(warn=-1) beforehand to suppress them as well.

Upvotes: 2

Related Questions