Can RStudio automatically generate an roxygen template for a function?
Asked Answered
D

4

43

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
Decorator answered 30/5, 2012 at 22:19 Comment(6)
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 siteDoddering
Something tells me this will happen soon.Bullhorn
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.Champlain
Seems to be available in Rstudio v0.99. (blog.rstudio.org/2015/05/06/…)Caslon
@crops can you post as an answer?Decorator
CTRL+ALT+SHIFT+R; from https://mcmap.net/q/390992/-keyboard-shortcut-for-inserting-roxygen-39-comment-startVirendra
H
37

(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

Holstein answered 5/6, 2015 at 20:19 Comment(0)
L
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...

Lemuel answered 12/7, 2012 at 21:24 Comment(2)
maybe worth deleting this answer now? (Out of date ...)Shields
@BenBolker I think it's a nice historical timestamp :)Parasynapsis
I
2

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

Indign answered 27/2, 2016 at 8:27 Comment(0)
R
1

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

Rhinoceros answered 5/1, 2015 at 4:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.