Help page examples

I'd like to see a button on the help pane, or a keyboard shortcut, to run the examples for the active help page. That is the more important and easily implemented part.

I'd like it even better if the results appeared at the bottom of the help page, or in a new window, rather than in the console.

1 Like

I agree that would be a convenience over cut-and-paste; however, the hard part is still going to be understanding the output and which parts of the input got you there, sadly. Inevitable part of a functional language with many possible arguments, not all of which are necessarily familiar.

You might be interested in rdocumentation.org, which allows examples to be run (and modified) in a cloud session very quickly :slightly_smiling_face:

2 Likes

In newer versions of RStudio (i think v 1.1.x and higher - although not entirely sure the first version it appeared) you are able to run the code in help files by highlighting it and then using the keyboard shortcut Ctrl + Enter

2 Likes

It was a 1.1 feature! :smile: Here's the blog post: https://blog.rstudio.com/2017/09/13/rstudio-v1.1---the-little-things/

@andrewH, I'm curious about this bit — do you just find it visually disruptive to have examples run in the console? Or do you mean that you'd prefer that they run in a completely independent R session?

For the latter (running an example without messing with my current environment/session), the reprex package and especially its Add-in can be helpful.

Cons:

  • You have to copy the example to a new script file and add the right library() statements
  • You still get reprex::reprex() output in the console

Pros:

  • Stuff created by the example stays out of your workspace/session
  • Example code and results all appear together in the RStudio Viewer pane

Also wanted to point out this collection of ideas from the github issue tracker:

2 Likes

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