Sebastian Zeki Sebastian Zeki - 21 days ago 4
R Question

Options for knit2html

I am getting fairly confused about setting options for the html output with knitr

I have an R script and I would like to create a report from it
To do this I am using spin from knitr as follows:

library(knitr)

s="/Users/sebastianzeki/MyRMonths.R"
spin(s)
o=spin(s,knit=FALSE)
knit2html(o,output="/Users/sebastianzeki/out.html")


My R script is very long but all I want to see is the FinalTable so I have done as follows:

#+results='asis'
knitr::kable(FinalTable)


However the final html contains everything, messages, errors etc etc from the whole script

Where can I adjust the options so i just see the table? Options to do this don't seem to be available in
knit2html
or in spin so I'm not sure out to adjust the options to get what I want

Answer

If you can, post a link to your script so the issue can be better diagnosed.

You most likely need to set the knitr chunk options to suppress warnings and messages. You can suppress errors, but your code will keep running if you do so. Include this near the top of your script.

#+ setup, include=FALSE
knitr::opts_chunk$set(warning = FALSE, message = FALSE)
Comments