MyNixOS website logo
Description

Analyze the File Contents of 'shiny' Directories.

Provides tools for analyzing and understanding the file contents of large 'shiny' application directories. The package extracts key information about render functions, reactive functions, and their inputs from app files, organizing them into structured data frames for easy reference. This streamlines the onboarding process for new contributors and helps identify areas for optimization in complex 'shiny' codebases with multiple files and sourcing chains.

shinyfa

shinyfa logo

Lifecycle: stable R-CMD-check

The {shinyfa} package is designed to help Shiny developers analyze and understand the file contents of large Shiny app directories.

Large Shiny applications often contain numerous files that define both dynamic UI and server components, sometimes linked together in complex sourcing chains (though this is less common in Shiny apps structured with modules). For new contributors—such as consultants joining a project—it can take considerable time to onboard, navigate the codebase, and identify areas for optimization.

This in-progress package aims to streamline that process by extracting key information from a Shiny app directory. It identifies specific render functions, reactive functions, and their inputs, organizing them into a structured data.frame for easy reference.

The fa in shinyfa stands for file analysis.

🎯 Why use shinyfa?

  • 📊 Audit reactive dependencies: Quickly understand which inputs affect which outputs across your entire app
  • 🔍 Identify unused code: Find reactive expressions and render functions that may no longer be used
  • 🗺️ Map data flow: Visualize how data flows through complex Shiny applications with multiple modules
  • 📚 Generate documentation: Create instant reference guides for new team members joining the project
  • ⚡ Optimize performance: Identify potential bottlenecks by understanding reactive chains

📦 Installation

Install from CRAN:

install.packages("shinyfa")

Or install the development version from GitHub:

# Install from GitHub
devtools::install_github("dalyanalytics/shinyfa")

# Or using pak
pak::pak("dalyanalytics/shinyfa")

🚀 Usage

Basic Example

Analyze a typical Shiny app structure:

library(shinyfa)
library(dplyr)

# Analyze server files in your Shiny app
server_files <- list.files("my_shiny_app/server", 
                          pattern = "\\.R$", 
                          full.names = TRUE, 
                          recursive = TRUE)

file_analysis <- data.frame()

for (file in server_files) {
  shiny_analysis <- analyze_shiny_reactivity(file_path = file)
  
  if (is.null(shiny_analysis)) next
  
  shiny_analysis$file_name <- basename(file)
  file_analysis <- bind_rows(file_analysis, shiny_analysis)
}

# View the analysis results
print(file_analysis)

Example Output

#>   type         name              inputs        output          file_name
#> 1 render       plotSales        c("dateRange", "product")  plotOutput     sales_module.R
#> 2 reactive     filteredData     c("selectedRegion")         NULL           data_processing.R  
#> 3 observe      updateFilters    c("input$reset")            NULL           ui_helpers.R
#> 4 render       tableSummary     c("filteredData")           tableOutput    summary_module.R
#> 5 observeEvent downloadHandler  c("input$download")         NULL           download_handlers.R

Analyzing Specific Patterns

# Find all reactive expressions that depend on a specific input
file_analysis %>%
  filter(type == "reactive", 
         grepl("dateRange", inputs)) %>%
  select(name, file_name)

# Identify potentially unused render functions
file_analysis %>%
  filter(type == "render",
         is.na(output) | output == "")

🔍 Scope & Limitations

  • File types: Supports .R files
  • Module support: Works with both traditional Shiny apps and modularized applications
  • Static analysis: Performs static code analysis without running the app
  • Pattern detection: May not catch all edge cases or dynamically generated reactives

🤝 Contributing

Contributions are welcomed!

  • Submit bug reports and feature requests via GitHub Issues
  • Fork the repository and submit pull requests for improvements
  • Help us improve documentation and add more examples

📄 License

MIT © Jasmine Daly / shinyfa authors.

Metadata

Version

0.0.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