rr-markdownknitr-spin

Use of @ in R programming, or R markdown?


I've downloaded code from another programmer, and they have the following:

#' @param gr                a GRanges of regions/DMRs/whatever
#' @param HMM               a GRanges with ChromHMM annotations (name, itemRgb)
#' @param background        a null distribution (universe) whence gr was chosen
#' @param footprint         compute BP footprints instead of number of overlaps?
#' 
#' @return                  a data.frame with overlap frequency and color code
#'
#' @export

I recognize the #' as syntax from knitr spin. But I don't understand how it's being used here or what the @ symbol is doing. Please explain.


Solution

  • The #' part is designating that this is part to be woven into proper R documentation through R package roxygen2. The @param are telling the translator to make these things into elements of the documentation.

    Example you posted will create a help file which will ultimately be viewed as

    functionName(gr, HMM, background, footprint)
    

    under Usage section of ?functionName and description of each argument under section Arguments and so on... See the link @joran provided (and stackoverflow tag description) about all available tags you can use to guide the way this inline documentation is made into a full blown .Rd file.