Using knitr in Rstudio, when an .Rmd file is knit to PDF, the resulting file viewer is evince. I would very much like to change this to okular, but I cannot find a way to make this happen.
Looking at the Sweave settings, I see "system viewer" noted for the preview, but okular is already set as my default system viewer. I've also checked the default viewer with xdg-mime and okular is default there as well. In all other instances, okular is the default but Rstudio/knitr always used evince.
How can I change this behavior?
Works on Mac, R Studio version 1.2.1335
Opitons | Sweave | PDF Viewer : System viewer
I recently had this problem and found a potential solution.
First, check to see what the default PDF viewer is set to:
Sys.getenv("R_PDFVIEWER")
Now, on my system this was "open", but it needed to be "xdg-open".
So, I changed the environmental variable:
Sys.setenv(R_PDFVIEWER = "xdg-open")
This may be permanently set by:
# Checking where your home directory is in R
Sys.getenv('HOME')
Then in terminal, in the home directory:
# Making an R environment file that runs at startup
touch .Renviron
# Add the environment variable change
echo 'R_PDFVIEWER = xdg-open' >> .Renviron
Now, when R starts the correct PDF viewer should be used.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With