# Create temporary directory and files
temp_dir <- tempfile()
dir.create(temp_dir)
# Create sample R files
writeLines(c(
"add <- function(a, b) { a + b }",
"calc <- function(x) { add(x, 10) }"
), file.path(temp_dir, "math.R"))
writeLines(c(
"process <- function(data) { add(data, 5) }"
), file.path(temp_dir, "process.R"))
# Analyze and plot - single file
graph <- plot_dependency_graph(file.path(temp_dir, "math.R"))
# Analyze directory
graph <- plot_dependency_graph(temp_dir)
# Exclude disconnected nodes
graph <- plot_dependency_graph(temp_dir, include_disconnected = FALSE)
# Clean up
unlink(temp_dir, recursive = TRUE)
Run the code above in your browser using DataLab