简体   繁体   中英

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM