问题
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