Sebastian Zeki
Sebastian Zeki

Reputation: 6874

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

Upvotes: 1

Views: 107

Answers (1)

Jake Kaupp
Jake Kaupp

Reputation: 8072

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)

Upvotes: 1

Related Questions