- Notifications
You must be signed in to change notification settings - Fork3
jeffjjohnston/RStudioConsoleRender
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
A short blog post about this package:Faster rendering in RStudio.
This package provides a single RStudio addin command calledRender in console. Executing it will callrmarkdown::render(active_document_path, envir=.GlobalEnv)
in the RStudio console and then launch a viewer for the resulting rendered document.
The effect is very similar to theCode |Run region |Run all command, except that it also renders your output document. Unlike theKnit button, however, it does not create a fresh environment. This has some important consequences to keep in mind.
First, packages loaded by your RMarkdown document will not need to be reloaded if they are already loaded in the console environment. This was my primary motivation for building the addin. My RMarkdown documents often depend on a set ofBioconductor packages, and these can take many seconds to load. If I'm making minor changes to a document and need to constantly render it to check the output, not having to reload packages each time is much faster.
Second, because rendering occurs in the console's environment, it is easy to introduce mistakes that you won't catch until you render in an empty environment via theKnit command. For example, if you load a package in your console environment but forget to load it in your RMarkdown document, the package will be available when you render via the console but not when you use theKnit command. I find that it is a good idea to periodically use theKnit command to make sure my RMarkdown document does not have any dependencies on the state of the console environment.
By default,RStudioConsoleRender
will callrstudioapi::viewer()
on the rendered document. This will typically open a browser window. You can control this behavior by setting theRStudioConsoleRender.viewer_mode
option to one of three values:
browser
: This is the default option and simply callsrstudioapi::viewer()
.viewer_pane
: This will open the rendered document in the RStudio Viewer pane by first copying it to the RStudio session temporary directory (a requirement of the Viewer pane).none
: No action will be performed after rendering the document when the option is set to this value.
Set the option usingoptions()
like this:
options("RStudioConsoleRender.viewer_mode"="viewer_pane")
Install the package viadevtools::install_github("jeffjjohnston/RStudioConsoleRender")
. TheRender in console command should then appear in RStudio'sTools |Addins drop-down menu. You can assign the command a keyboard shortcut usingTools |Modify Keyboard Shortcuts....
About
Provides an RStudio addin command to render the current Rmarkdown document in the console
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.