42

Does RStudio support any automated roxygen template creation?

In Emacs-ESS, C-x C-o will produce an roxygen template for a function. For example, it will automagically convert this:

foo <- function(x,y) x+y

into this:

##' .. content for \description{} (no empty lines) ..
##'
##' .. content for \details{} ..
##' @title 
##' @param x 
##' @param y 
##' @return 
##' @author David
foo <- function(x,y) x+y

Does similar functionality exist within RStudio?

updates

  • as of ESS 12.09-2, the command has been changed to C-c C-o C-o
  • this feature has been implemented in Rstudio: CTRL+ALT+SHIFT+R
David LeBauer
  • 31,011
  • 31
  • 115
  • 189
  • 2
    For future reference: The RStudio devs are really good at taking feedback and suggestions. You can always make a suggestion and voice your opinion on features you want to see at the [RStudio support site](http://support.rstudio.org/) – Dason Jul 12 '12 at 23:24
  • [Something](http://chat.stackoverflow.com/transcript/message/5009687#5009687) tells me this will happen soon. – Ari B. Friedman Aug 20 '12 at 18:05
  • 1
    In my case, using ESS 12.04-4, it's `C-c C-o C-o`. It's also available from the EMACS menu bar via `ESS` --> `Roxygen` --> `Update/Generate Template`. – dardisco Mar 30 '13 at 00:04
  • 1
    Seems to be available in Rstudio v0.99. (http://blog.rstudio.org/2015/05/06/rstudio-v0-99-preview-more-editor-enhancements/) – Crops May 16 '15 at 10:01
  • @crops can you post as an answer? – David LeBauer May 20 '15 at 00:38
  • 1
    `CTRL+ALT+SHIFT+R`; from https://stackoverflow.com/a/36727983/4612235 – daniel.heydebreck Sep 08 '17 at 16:09

4 Answers4

36

(Converting @Crops comment into a full answer)

In RStudio v0.99 there is a new option under the "Code" menu for .R files: "Insert Roxygen Skeleton". There is an image of it in RStudio's blog post about v0.99 preview.

Roxygen skeleton menu image from RStudio

Brian Diggs
  • 57,757
  • 13
  • 166
  • 188
9

The silence that followed your question should tell you something... The answer, currently, is NO is doesn't. I know of several people who use EMACS for precisely this reason, and would not consider switching to RStudio until that has full roxygen support. That said, there has been some discussion about this between users and the makers of RStudio. Considering all the cool things that have been added to RStudio recently, I would not be surprised to see it happen. In fact, I think it is quite likely it will happen. But don't hold your breath for it, it may be a long wait...

Peter Verbeet
  • 1,786
  • 2
  • 13
  • 29
2

Alternatively you can use the R package RoxygenReady to create Roxygen skeletons / Roxygen templates.

bud.dugong
  • 689
  • 7
  • 16
1

My solution was to use a text expander (PhraseExpress in my case) to do this.

s6mike
  • 497
  • 5
  • 16