describefunctions: describefunctions lists all R functions in a set of files

View source: R/rutils.R

describefunctionsR Documentation

describefunctions lists all R functions in a set of files

Description

describefunctions lists all the R functions in a set of R files along with their syntax, the linenumber in each file, the filename, the function name, and the functions within the set of R files that each function calls. In addition, there is now a crossreference column, which identifies which functions call each function. If just the indir is provided then all R files in that directory will be examined. .Rmd files will not be considered but any other file type starting with .R may cause trouble until I find a fix!

Usage

describefunctions(indir, files = "", outfile = "", sortby = "functions")

Arguments

indir

the directory in which to find the R files

files

a vector of filenames, as character, within which to search for functions, default="", which means all R files in indir will be used

outfile

the full path and name of the CSV file to which the results should be saved. default="", which means the output will only be returned invisibly. If outfile has a fullpath csv filename then it will also be written to that file as well as retunred invisibly

sortby

how should the output be sorted? deffault = "functions", which means the functions will be sorted by name. The alternative is "file", which will sort the output by input filename

Value

It can produce a csv file but also returns the results invisibly

See Also

findfuns, identifyfuns

Examples

filen <- tempfile("test",fileext=".R")
txt <- c("# this is a comment",
 "#' @title ...",
 "dummy <- function() {",
 "  out <- anotherdummy()",
 "  return(out)",
 "}",
 "# a possibly confusing use of function",
 "#' @title ...",
 "anotherdummy <- function() {",
 "  return(NULL)",
 "}",
 "  ")
 write(txt,file=filen)
 usedir <- paste0(tempdir(),"//")
 filename <- tail(unlist(strsplit(filen,"\\",fixed=TRUE)),1)
 x <- describefunctions(indir=usedir,files=filename,outfile="")
 x

haddonm/codeutils documentation built on April 15, 2024, 1:02 p.m.