funviewR is an R package that analyzes R source code to detect function definitions and internal dependencies, then visualizes them as interactive network graphs.
visNetworkplot_dependency_graph()You can install the development version from GitHub:
# Install remotes if you don't have it
install.packages("remotes")
# Install funviewR from GitHub
remotes::install_github("deamonpog/funviewR")The easiest way to visualize dependencies:
library(funviewR)
# Analyze files or directories - auto-detects which is which!
plot_dependency_graph(c("R/", "analysis.R", "tests/"))
# Single directory
plot_dependency_graph("R/")
# Specific files
plot_dependency_graph(c("script1.R", "script2.R"))
# With options
plot_dependency_graph("src/",
recursive = TRUE,
include_disconnected = FALSE)For more control and access to analysis data:
library(funviewR)
# Step 1: Analyze files
file_paths <- c("path/to/your/script.R")
dep_info <- analyze_internal_dependencies_multi(file_paths)
# Step 2: Create visualization
plot_interactive_dependency_graph(dep_info)# Get all R files from a directory
files <- get_r_files("R/")
# Get R files recursively
files <- get_r_files("R/", recursive = TRUE)
# Then analyze
dep_info <- analyze_internal_dependencies_multi(files)
graph <- plot_interactive_dependency_graph(dep_info)# Mix files and directories - automatically detected!
plot_dependency_graph(c(
"R/core/",
"main.R",
"R/utils/",
"tests/",
"helpers.R"
), recursive = TRUE)The analyze_internal_dependencies_multi() function
returns a list containing:
dependency_map: A list mapping each function to its
dependenciesenv: Environment containing all defined functionsall_code_lines: All code lines from analyzed filesfunction_file_map: Maps function names to their source
filesduplicates: Lists functions defined in multiple
files# Access the dependency map
dep_info$dependency_map
# Check for duplicate function definitions
if (length(dep_info$duplicates) > 0) {
print("Warning: Duplicate functions found:")
print(dep_info$duplicates)
}The interactive graph provides:
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the GNU General Public License v3.0
Chathura Jayalath - Email: acj.chathura@gmail.com