As a new Emacs user, I've recently learned how to use polymode to handle R code in org-mode. I'm happy with it, since I get the same features than those implemented for example in Rstudio for Rmd files (e.g., facilities to execute code chunks and visualize the results directly in the org file, display inline images, code completion in code chunks, etc.).

Even if I prefer now working with org-babel than rmarkdown, I wonder if it is possible to get the same features for Rmd files with polymode.

With my current settings, when working on an Rmd file, code completion works properly inside R chunks, and R chunks can be executed (i.e., sent to an inferior R process) by C-c C-c. Everything is okay for that. But I don't understand how to display/preview/visualize the results and plots produced by R chunks directly within the Rmd file, and I don't even know if it is possible. All the chunks are sent and executed in a separate R buffer, but it would be more convenient to have the results displayed just below the chunks, as with org-babel.

All information is welcome :)

1 Answer 1


Your R output will be put in the file(s) produced by running knitr on your .Rmd file. IMHO, it doesn't make sense to have it inserted in the .Rmd file itself since that's 'input' not 'output'.

I don't work in org-mode (yet?), but my understanding is that when working in that mode, it's possible to have the graphics output displayed in an emacs window. See here for more details.

I do wish this was possible with poly-r. I have considered trying to output my graphics as a PDF or PNG file, which can be displayed in an emacs' window with the file reloaded each time it changes. However, I haven't done it yet.

Finally, I am curious to know what your poly-r settings are since I don't get command completion within my R chunks in my .Rmd files. I'd love to have that ability.

  • 1
    I figured out how to get auto-complete in my Rmd chunks! I needed to install and load the melpa package company (not autocomplete which is depricated). It's pretty darn sweet! Jul 13, 2020 at 22:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.