Suppress output of stationarity test that is printed to screen

守給你的承諾、 提交于 2019-12-05 09:32:43

In fact, you can suppress the output to R console by rerouting it. Two methods are available in R utils, sink, and capture.output. Both methods are intended to send output to a file.

Since you want to suppress the output of a single expression, you can use capture.output, with file=NULL (default). This will return your output as a string. To prevent showing this returned string in the R console, you can use invisible.

The final code can be:

library(fractal)

lg.day.ret.vec <- rnorm(100, mean = 5, sd = 3)
shap.p <- shapiro.test(lg.day.ret.vec)$p.value

invisible(capture.output(
    stat.p <- attr(stationarity(lg.day.ret.vec),"pvals")[1]
))

Hope this helps. Let me know if not.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!