【问题标题】:knitr, suppress nms stress from vegan metaMDSknitr,抑制来自纯素 metaMDS 的 nms 压力
【发布时间】:2018-08-01 00:55:52
【问题描述】:

我想编写带有 NMS 排序的报告。我想在报告中包含代码,但不是运行压力。

我已经尝试过message=FALSE, warning=FALSE, results='hide',但它仍然包含在报告中。

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  

我只想要

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

如果它有助于弄清楚如何抑制不需要的结果,这是我的 knitr 选项和我的报告的屏幕截图

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

更新。抱歉,应该包括使用纯素数据集。

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

vegan 中的解决方案比 capture.output 更直接(也有效)

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

【问题讨论】:

    标签: r knitr vegan


    【解决方案1】:

    基于this answer,可以试试:

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

    我只是在使用 mtcars 数据集时收到警告,不确定您是否这样做,但您也可以事先使用 options(warn=-1) 来抑制它们。

    【讨论】:

    • trace = FALSE 抑制计算的跟踪和静默metaMDS(并且trace = 2 比默认值更大)。参数trace 已记录在案,如果将来其他一切都失败了,我建议您考虑阅读文档。
    • 我不知道什么是“跟踪函数;trace = 2 或更高会更大。”意思是直到这条评论。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-01
    • 1970-01-01
    • 2015-08-10
    • 1970-01-01
    • 2014-03-01
    • 1970-01-01
    相关资源
    最近更新 更多