How to set up a chunk to only run when knitting?

In order for my histograms from skimr to knit properly, I need to call the skimr::fix_windows_histogram()
function in my Rmarkdown document. This works well, but I don't need or want this function to run when using R interactively because it prompts the user in the console to confirm it and locks down execution. Is there a chunk option or function wrapper that makes it so this function will only run when knitting? Or is there a way to automatically confirm the prompt?

Would adding if (!interactive()) {code goes here} work?

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.