keyboard shortcut to run @examples?

When developing new R functions, I continually reload the function ("cmd + enter"), but then I want to run the examples in @examples in the function's roxygen2 docs. For example:

#' My new function
#' @examples
#' my_function()
my_function <- function(){
  2 + 2

I can load my function easily via "cmd + enter" (cursor at the first or last line of the function), which moves my cursor to the end of the function.

I then want to run my_function() from @examples, but I have to move my cursor up to @examples, which arduous for long functions.

I can't find the keyboard shortcut for auto-running the code in @examples. Any help would be appreciated!

Unfortunately this is difficult to solve in general, because a function might be documented in another manual page, a roxygen chunk does not always correspond to a complete manual page, etc.

Maybe you could write an addin for the simple case.

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.