Documenting setter functions with roxygen

前端 未结 1 2003
一生所求
一生所求 2021-01-05 14:48

I have a function that does nothing more than ads a unique attr to any R object. Base demo:

#\' Setter function
#\' @param x an R object
#\' @pa         


        
相关标签:
1条回答
  • 2021-01-05 15:22

    You can use the roxygen tag @usage

    Here is an example from one of my packages:

    #' @rdname pattern
    #' @usage pattern(x) <- value
    #' @param value New value
    #' @export pattern<-
    "pattern<-" <- function(x, value=c("^", "($|(_\\d+(_\\d+)*)$)")){
      attr(x, "pattern") <- value
      x
    }
    

    This results in my desired documentation:

    Usage
    
      pattern(x) <- value
    
    Arguments
    x surveydata object
    
    value New value
    
    0 讨论(0)
提交回复
热议问题