I have suppressed warnings in knitr output but the warnings do not show up in the Rmarkdown console as expected. How do I view these?

左心房为你撑大大i 提交于 2021-02-11 07:26:51

问题


I am using Knitr and rmarkdown. I have suppressed warnings in the .pdf output and then typically the warnings are listed in the rmarkdown console. However, in the case of one specific report, instead of getting the warnings listed in the rmarkdown console, I get this message: There were 15 warnings (use warnings() to see them). Where do I write this warnings() code to see the list of warnings?

I have tried adding warnings() at the bottom of my rmarkdown document but the output is: NULL.


回答1:


If you are using an .rmd file, you will need to knit that file through an r script to produce the errors in the console, becuase .rmd files use unique consoles for each R call. Try this:

setwd("C:/blah/blah")
knitr::knit("blah.Rmd")
warnings()



回答2:


If you type warnings() in the console it will show you that last 15. The console in this environment works predominately the same way that it does in a script. Anything you type is run line, by line, but you are working in the same global environment.



来源:https://stackoverflow.com/questions/40474305/i-have-suppressed-warnings-in-knitr-output-but-the-warnings-do-not-show-up-in-th

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