MyNixOS website logo
Description

Visualize Function Call Dependencies in R Source Code.

Provides tools to analyze R source code and detect function definitions and their internal dependencies across multiple files. Creates interactive network visualizations using 'visNetwork' to display function call relationships, with detailed tooltips showing function arguments, return values, and documentation. Supports both individual files and directory-based analysis with automatic file detection. Useful for understanding code structure, identifying dependencies, and documenting R projects.

funviewR

License: GPL v3 R CRAN

funviewR is an R package that analyzes R source code to detect function definitions and internal dependencies, then visualizes them as interactive network graphs.

Features

  • 📊 Analyze R code dependencies - Automatically detect function definitions and calls
  • 🔍 Multi-file & directory support - Analyze multiple R files and directories together
  • 🤖 Auto-detection - Automatically detects whether paths are files or directories
  • 📈 Interactive visualization - Create beautiful dependency graphs with visNetwork
  • 🔧 Detailed tooltips - View function arguments, return values, and documentation
  • 🎯 Smart layout - Hierarchical graph layout with most-connected nodes centered
  • ⚠️ Duplicate detection - Identify functions defined in multiple files
  • One-line plotting - Quick visualization with plot_dependency_graph()

Installation

From GitHub

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")

Usage

Quick Start (One-Line Solution)

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)

Advanced Usage (Two-Step Process)

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)

Working with Directories

# 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)

Analyzing Multiple Sources

# Mix files and directories - automatically detected!
plot_dependency_graph(c(
  "R/core/",
  "main.R",
  "R/utils/",
  "tests/",
  "helpers.R"
), recursive = TRUE)

Working with the Results

The analyze_internal_dependencies_multi() function returns a list containing:

  • dependency_map: A list mapping each function to its dependencies
  • env: Environment containing all defined functions
  • all_code_lines: All code lines from analyzed files
  • function_file_map: Maps function names to their source files
  • duplicates: 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)
}

Example Output

The interactive graph provides:

  • Blue boxes: Defined functions with full metadata
  • Gray ellipses: External or undefined functions
  • Arrows: Function call relationships
  • Tooltips: Hover over nodes to see:
    • Function arguments
    • Return values
    • Source file
    • Documentation (if available)

Requirements

  • R >= 3.5.0
  • codetools
  • visNetwork
  • igraph
  • htmltools
  • magrittr

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the GNU General Public License v3.0

Author

Chathura Jayalath

Acknowledgments

  • Built with visNetwork for interactive graph visualization
  • Uses R's codetools for dependency analysis
  • Leverages igraph for graph algorithms and distance calculations
  • Uses htmltools for safe HTML rendering
  • Powered by magrittr pipe operator.
Metadata

Version

0.1.1

License

Unknown

Platforms (78)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    uefi
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-uefi
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-linux
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-uefi
  • x86_64-windows