I\'m fairly new to R, and I have been defining some of my own functions in script files. I\'m intending for others to re-use them later, and I can\'t find any guides on R fu
Another (and lower key) alternative you could look into are the comment() and attr() functions to add some meta data to your functions. Here's a quick and silly example:
FOO <- function(x,y) {
x + y
}
attr(FOO, "comment") <- "FOO performs simple addition"
#This can be arbitrary. "comment" is special. see ?comment for details.
attr(FOO, "help") <- "FOO expects two numbers, and it will add them together"
You can then see everything associated with FOO by using attributes():
> attributes(FOO)
$source
[1] "function(x,y) {" " x + y " "}"
$comment
[1] "FOO performs simple addition"
$help
[1] "FOO expects two numbers, and it will add them together"
Or extract specific parts:
> attr(FOO, "help")
[1] "FOO expects two numbers, and it will add them together"
attr(FOO, "comment")
[1] "FOO performs simple addition"
And in the case of comment, use comment():
> comment(FOO)
[1] "FOO performs simple addition"
In the long term, writing your own package will almost certainly be worth the overhead and time investment, but if for some reason that isn't practical in the short term - here's another option.