Can RStudio automatically generate an roxygen temp

2019-02-03 23:25发布

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

4条回答
我欲成王,谁敢阻挡
2楼-- · 2019-02-03 23:35

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

查看更多
欢心
3楼-- · 2019-02-03 23:45

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...

查看更多
甜甜的少女心
4楼-- · 2019-02-03 23:48

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

查看更多
再贱就再见
5楼-- · 2019-02-03 23:55

(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

查看更多
登录 后发表回答