# functionMap v1.0.0

## Draw the Function Map for a R Package

Extract all function calls from an R package, or a set of R scripts. Create a network of functions that can be then visualized. Can also extract the places of the function definitions and function calls and export them in a 'JSON' file.

# functionMap

Function Map of an R Package

Extract all function calls from an R package, or a set of R scripts. Create a network of functions that can be then visualized. Can also extract the places of the function definitions and function calls and export them in a 'JSON' file.

## Installation

source("https://raw.githubusercontent.com/MangoTheCat/remotes/master/install-github.R")\$value("mangothecat/functionMap")


## Usage

library(functionMap)


Use the map_r_script to map a single R script, map_r_folder to recursively map a folder of R files, or map_r_package to map an R package.

All three functions return a function_map object, that can be printed, exported and visualized.

### Pretty printing

The default function_map print method lists the function calls in a nice form. For packages, exported functions are marked with a star, and calls to other packages are highlighted with a different color.

 Name Description actively_find_funcs Try harder to find functions that are called default_r_file_pattern Default pattern for R files add_namespaces Add namespace information to a map of an R package check_pkg_dir Check if a path is an R package root directory data_frame Alternative to data.frame create_function_map Create a function_map object from a parsed result deps Dependencies of all functions bfs Perform a breadth first search (BFS) on a graph drop_null Drop NULL elements from a list common_prefix The longest prefix of both lists extract_if_needed Extract a package tarball find_imports Check if a list of function names were imported from a package edge_df Extract data about the edges (function calls) in a function map find_globals_multiple Find all (non-local) function calls in a function, keep multiple calls external_calls Find calls to external functions find_globals Find all (non-local) function calls in a function export_map Export a map to a JSON file edge_data_frame Extract edge (= function call) metadata from the call graph find_in_named_list Find an element within entries of a named list func_arg_globals Find the global functions that are used as arguments funcs_from_exprs Get functions from a list of expressions get_funcs_from_r_script Extract all functions from an R script get_exports Get exported functions from a package, from NAMESPACE get_base_funcs Names of all functions in the base package get_global_calls Get global function calls from a function functions_called All functions that called in a package or R script functions All functions of a function map of a package or script func_from_expr Get funcion(s) from a single expression. Usually a single function, but not necessarily. get_graph Convert a function map to a directed graph get_imports Table of imported functions map_cran_package Create the map of a CRAN package in_list Check if an object is in a list node_data_frame Extract vertex (= function) metadata from the call graph node_df Extract data about the functions in a function map isolates Vertices that cannot be found from the a set of source vertices map_r_script Map the function calls for an R script map_r_folder Map the function calls for a folder of R scripts map_r_package Map an R package myrep Recycle a vector or a data frame (rows) maybe_s3_method Predicate to pre-filter possible S3 methods parse_collate Parse the Collate field of package DESCRIPTION r_package_files Get all source files of a package, in the right order remove_base_functions Remove base function names form a data frame of functions topo_sort Topological sort of a graph str_trim Trim leading and trailing whitespace from a character vector parse_r_script Find all function calls in an R script parse_r_folder Parse one or more folders of R scripts print.function_map Print method for a function map object. where Try to find where some called functions live with_package Evaluate an expression with a package loaded remove_loops Remove loops from a graph unused_functions Functions that are never used in a package rev_deps Reverse dependencies of all functions twist_graph Change the direction of each edge to the opposite in a graph s3_calls Find the S3 methods of a function, in an environment package_name Get the name of the package from DESCRIPTION package_collate Collate field from DESCRIPTION sankey_plot Sankey plot of a function map No Results!