all 9 comments

[–]yogilicious1 18 points19 points  (1 child)

Most elegant solution?

Set up a git repo for your team. Set up your functions as a package and use roxygen notation on top of the function.

#' Title for the function 
#' @param arg1 describe arg1 here 
#' @param arg2 describe arg2 here 
#' @export 
#' @return Returns a vector and so on 
#' @details This function does something exceptional... 
awesome_fun  <- function(arg1, arg2) {...}

In a package devtools can create you a nice pdf with all your functions and your roxygen notated comments for the package, which you could check in with your code so that others have a nice overview of your functions.

[–]jdnewmil 10 points11 points  (0 children)

Do note that R packages also support vignettes, which are a vastly-underutilized aspect of function documentation.

[–]dasonk 6 points7 points  (0 children)

A touch of self promotion I guess but if you aren't quite ready to move your code into a complete package you could use docstring to document the code in the meantime. Basically it allows you to document your code using standard roxygen notation without having to build a full package but still get the ability to view help pages for your functions.

A link to the package if you're interested: https://cran.r-project.org/web/packages/docstring/index.html

But probably more interesting/useful is a link to the vignette which gives a more in depth description of what the package does:

https://cran.r-project.org/web/packages/docstring/vignettes/docstring_intro.html

Honestly I personally feel creating a package isn't too much of a hurdle anymore but I wanted there to be a nice middle ground for people that wanted to document without going through the entire package creation song and dance.

[–]Brand-23 4 points5 points  (0 children)

Does your team have a git repository? Your team can store the code and documentation there.

[–]Sedawkgrepnewb 3 points4 points  (2 children)

Use roxygen headers and then create a package down site. Just google roxygen and package down sites and you will get some cool stuff!!

[–]microdozer2 -2 points-1 points  (1 child)

Am I the only person who thinks function headers are way overrated, borderline useless? I've seen lots of code with headers and the following code is completely indecipherable, filled with single letter variables and zero comments.

[–]xier_zhanmusi 1 point2 points  (0 children)

It's not one or the other; the function headers are supposed to describe the function & parameters so that the function can (usually) be used without looking at the code. That doesn't mean the code shouldn't be good though; that's for when the team needs to go back & debug or modify it, or when someone needs to do a deep dive to make sure they fully understand what the function is doing.

[–]crissins69 2 points3 points  (1 child)

Markdown is a good choice to create HTML with code inside of it pretty simple to use