Use RStudio environment in normal R console

I wrote a nice R script that takes a bibtex document and makes a clickable lit review in html using Bookdown.

However one thing that is frustrating is that even though I am writing in sublime text and only need to run my "build" script pretty rarely, I still need to use RStudio to compile the document. This is because using Bookdown in Rstudio makes R look for Rstudio's own pandoc installation, which has the correct version of Pandoc's Citeproc.

When I run it in the plain old R Console GUI app, which I prefer since a) it's faster to write commands in and b) I like how help windows open in a new browser tab rather than a new pane, bookdown looks at my computer's default pandoc installation, which apparently doesn't have the right add-ons.

Is there any way that I can start the basic R Console so it has the exact same behavior as my r studio console? I would prefer this solution than trying to install the right set of pandoc add-ons.

In all, I really don't like how code has different behaviors based on the IDE I am using to run it. Is there any work to make this not the case?

Thank you

I think that doing this would require that you install the right set of pandoc add-ons, regardless of whether or not you are in the IDE.

Yihui answers this specific question re. using RStudio pandoc in his post below:


(I'm adding an excerpt below, but you should probably look at the full post, since I'm not sure this covers all the steps).

If you want RStudio’s Pandoc to be available system-wide, you can add its path to the system environment variable PATH . The path can be found in the environment variable in RStudio:

Sys.getenv('RSTUDIO_PANDOC')

Thanks for the quick reply! I will look into adding the correct cite-proc add-on.

If possible, could you explain why bookdown can't just point to it's own pandoc installation and ignore the global pandoc path every time it is run?

There is an explanation confirming the limitation here, but no details as to why bookdown can't just look for the one it was installed with.

Good question. Unfortunately the answer is "no". Ideally we should allow users to choose a specific version of Pandoc in rmarkdown, but currently rmarkdown only looks for the highest version of Pandoc in your system.

I think my solution is most likely to uninstall the version of pandoc I added earlier (I can't remember why I did that in the first place).

Edit: Ah I see. this choice was actually to make it less dependent on Rstudio. I didn't realize that the pandoc download was Rstudio's doing, not Bookdown's. I am not familiar with the limitations R has with downloading executables, but it would be great if bookdown could check for pandoc compatibility and download missing elements as needed on its own. So if it sees a newer version of pandoc, to add the citeproc add-on. But that could turn into a dependency mess. These are hard problems!

EDIT: it turns out my miniconda installation also installed pandoc! Who knows how many pandocs I actually have on my computer. Maybe the solution is for pandoc to start bundling citations with its executable

PS: To anyone saying that you should keep a bibtex file with markdown notes stored in the comment field, don't! Bibtex and jabref delete line breaks when they open or edit .bib files. So all the markdown formatting will go out the window if someone else decides to even open the file you've worked on.

1 Like

I think, as you're finding out, there's a lot going on with the Pandoc part of the stack which is further down than my knowledge goes (and, as you can tell from Yihui's post, is outside the realm of RMarkdown control — or knitr, for that matter, which is another one of Yihui's packages). Bookdown being an extension of RMarkdown, the same holds for it as well.

Yihui's book might shed a bit more light on things (the preface gets into the stack used by R Markdown a bit — the whole thing is free online at the link).

1 Like

Update:

for whatever reason, it has started working. I think reinstalling or updating bookdown did the trick. This is strange since

> rmarkdown:::pandoc_version()
[1] ‘1.19.2.1’

means it wasn't due to some pandoc 2.0 breaking change.

However R is still pointing to my pandoc in my Minconda3 folder. This is fine, since citeproc is there, too. I'm not sure how to add the citepreoc .exe on Windows 10, so I'm thankful the package distributors bundle it.

1 Like

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