pkgCodeInfo | R Documentation |
These functions analyze the code in an R file or a collection of R files in a directory (not necessarily a formal package) and returns a description summarizing the top-level objects in the code, i.e., functions, methods, variables.
It ignores code in if(FALSE)
expressions.
pkgCodeInfo(dir, rfiles = getRFiles(dir, recursive = recursive), recursive = TRUE)
fileCodeInfo(file, code = parse(file), addClass = TRUE)
dir |
the path to a directory containing the R code, or a file |
rfiles |
the full paths to the files to process, useful if one only wants to process a subset of the files in the directory or combine files from multiple directories. |
recursive |
a logical value passed to |
file |
the full path to the R file containing the code to process |
code |
the R code to analyze |
addClass |
a logical value indicating whether to add the |
A data.frame with 6 elements:
name |
the name of the top-level object |
type |
the R type |
op |
the top-level operation, often '=' or '<-', but also calls to Vectorize, setAs, setGeneric, ... |
expr |
a list of the R code/language objects |
file |
the name of the file in which the expression is located |
index |
the index of that top-level expression in that file. |
Duncan Temple Lang
dir = system.file("sampleCode", package = "CodeAnalysis")
info = pkgCodeInfo(dir)
dim(info)
table(info$op)
table(info$file)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.