Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Provides an RStudio addin command to render the current Rmarkdown document in the console

NotificationsYou must be signed in to change notification settings

jeffjjohnston/RStudioConsoleRender

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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.

Viewer options

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")

Installation

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

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp