tonytonov tonytonov - 20 days ago 5
R Question

Do not open RStudio internal browser after knitting

I'm working on a presentation in RStudio using rmarkdown and revealjs template. Since it's a work in progress, I often knit the .Rmd file to see the changes.

The problem is, each time I press "Knit" button (or use a hotkey), an internal browser window pops up. I don't need it, really, because 1) it displays the presentation incorrectly and 2) I already have the .html file open in my system browser and I simply refresh the page.

Is there any way to suppress the default RStudio behaviour?

Ideally, I'd love to be able to knit and see the result in the system browser (with focus on it) in as few keypresses as possible. Right now, my solution is to

source(render.R)
, which contains a call like

library(rmarkdown)
library(revealjs)
render("main.Rmd",
revealjs_presentation(theme="black", highlight="zenburn"),
encoding = "UTF-8")


Better than nothing, but still a bit tedious (set focus from editing to console, source, refresh page -- 3 actions). Any suggestions?

For an MWE, open [New File] -- [R Markdown...] and hit "Knit HTML" or Ctrl+Shift+K.

Answer

RStudio keeps moving this feature around. Johnathan's answer was good for the prior version of RStudio that I was using. You could find it starting with Tools > Global Options and then if you are on 0.99.x, here:

enter image description here

I'm currently on 1.0.44 and now it's here:

enter image description here

In all fairness to RStudio, I think creating a new R Markdown option section and putting it here makes good sense.

Comments