{"id":38820655,"url":"https://github.com/lewinfox/foodwebr","last_synced_at":"2026-01-17T13:04:16.158Z","repository":{"id":44387291,"uuid":"364472144","full_name":"lewinfox/foodwebr","owner":"lewinfox","description":"Function dependency graphs in R","archived":false,"fork":false,"pushed_at":"2025-10-01T00:53:00.000Z","size":1585,"stargazers_count":30,"open_issues_count":1,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-10-01T02:43:44.829Z","etag":null,"topics":["code-tools","function-dependency","introspection","r"],"latest_commit_sha":null,"homepage":"http://www.lewinfox.com/foodwebr/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lewinfox.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-05-05T05:37:03.000Z","updated_at":"2025-10-01T00:41:59.000Z","dependencies_parsed_at":"2024-02-18T09:28:56.115Z","dependency_job_id":"1de92d41-35d6-4953-b8f6-2eef188e34ce","html_url":"https://github.com/lewinfox/foodwebr","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/lewinfox/foodwebr","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lewinfox%2Ffoodwebr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lewinfox%2Ffoodwebr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lewinfox%2Ffoodwebr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lewinfox%2Ffoodwebr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lewinfox","download_url":"https://codeload.github.com/lewinfox/foodwebr/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lewinfox%2Ffoodwebr/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28508943,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T11:50:55.898Z","status":"ssl_error","status_checked_at":"2026-01-17T11:50:55.569Z","response_time":85,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["code-tools","function-dependency","introspection","r"],"created_at":"2026-01-17T13:04:15.463Z","updated_at":"2026-01-17T13:04:16.151Z","avatar_url":"https://github.com/lewinfox.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput: github_document\nalways_allow_html: true\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\",\n  fig.height = 2\n)\n```\n\n```{r, include = FALSE}\nif (!requireNamespace(\"cowsay\", quietly = TRUE)) {\n  install.packages(\"cowsay\")\n}\n```\n\n# foodwebr\n\n\u003c!-- badges: start --\u003e\n[![R-CMD-check](https://github.com/lewinfox/foodwebr/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/lewinfox/foodwebr/actions/workflows/R-CMD-check.yaml)\n\u003c!-- badges: end --\u003e\n\n`foodwebr` makes it easy to visualise the dependency graph of a set of functions \n(i.e. who calls who). This can be useful for exploring an unfamiliar codebase, \nor reminding yourself what you wrote ten minutes ago\n\n## Installation\n\nYou can install foodwebr from CRAN:\n\n``` r\ninstall.packages(\"foodwebr\")\n```\n\nor from GitHub:\n\n``` r\ndevtools::install_github(\"lewinfox/foodwebr\")\n```\n\n## Basic usage\n\nSay we have a bunch of functions in the global environment, some of which call \neach other:\n\n```{r setup}\nlibrary(foodwebr)\n\nf \u003c- function() 1\ng \u003c- function() f()\nh \u003c- function() { f(); g() }\ni \u003c- function() { f(); g(); h() }\nj \u003c- function() j()\n```\n\nA call to `foodweb()` will calculate a graph of the dependencies.\n\n```{r foodweb-basic}\nfw \u003c- foodweb()\n```\n\nPrinting the object will show the [graphviz](https://graphviz.org/) \nrepresentation:\n\n```{r foodweb-print}\nfw\n```\n\nPlotting will draw the graph.\n\n```r\nplot(fw)\n```\n\n![](man/figures/README-foodweb-plot-1.png)\n\n`foodweb()` looks at its calling environment by default. If you want to look at \nanother environment you can either pass a function to the `FUN` argument of \n`foodweb()` or pass an environment to the `env` argument. If `FUN` is provided \nthen the value of `env` is ignored, and the environment of `FUN` will be used.\n\n### Filtering\n\nIf a specific function is passed to `FUN`, the default behaviour is to remove \nfunctions that are not descendants or antecedents of that function.\n\n```{r foodweb-filter}\n# `j()` will not be included\nfoodweb(FUN = g)\n\n# Force inclusion of unconnected functions by using `filter = FALSE`\nfoodweb(FUN = g, filter = FALSE)\n```\n\nYou can use this feature when exploring code in other packages: calling \n`foodweb()` on a function in another package will show you how functions in that \npackage relate to each other. I'm using `cowsay` here as it's small enough that \nthe output is readable.\n\nBy default when calling `foodweb()` on a specific function we only see functions \nthat are in the direct line of descendants or antecendents of the specified \nfunction.\n\n``` r\nif (requireNamespace(\"cowsay\", quietly = TRUE)) {\n  plot(foodweb(cowsay::say))\n}\n```\n\n![](man/figures/README-foodweb-plot-package.png)\n\nIf we want to include _all_ functions in the package, we can pass \n`filter = FALSE`:\n\n```r\nif (requireNamespace(\"cowsay\", quietly = TRUE)) {\n  plot(foodweb(cowsay::say, filter = FALSE))\n}\n```\n\n![](man/figures/README-foodweb-plot-package-no-filter.png)\n\n### Extra `graphviz` options\n\nIn case you want to do something with the [graphviz](https://graphviz.org/) \noutput (make it prettier, for example), you can pass additional arguments to \n`plot()`. These will be passed directly to `DiagrammeR::grViz()`.\n\n### Foodweb as text\n\n```{r foodweb-as-text}\nfoodweb(as.text = TRUE)\n```\n\nCalling `as.character()` on a `foodweb` object will have the same effect.\n\n\n## Using `tidygraph`\n\nThe [`tidygraph`](https://tidygraph.data-imaginist.com/) package provides tools \nfor graph analysis. A `foodweb` object can be converted into a tidy graph object \nusing `tidygraph::as_tbl_graph()` to allow more sophisticated analysis and \nvisualisation.\n\n```{r foodweb-tidygraph}\nif (requireNamespace(\"tidygraph\", quietly = TRUE)) {\n  tg \u003c- tidygraph::as_tbl_graph(foodweb())\n  tg\n}\n```\n\n\n## See also\n\n`foodwebr` is similar to these functions/packages:\n\n* [`mvbutils::foodweb()`](https://cran.r-project.org/package=mvbutils): The OG \n  of function dependency graphs in R, and the inspiration for\n  foodwebr. Less user-friendly output, in my opinion.\n* [`DependenciesGraphs`](https://github.com/datastorm-open/DependenciesGraphs): \n  Provides much nicer visualisations but does not appear to be actively \n  maintained.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flewinfox%2Ffoodwebr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flewinfox%2Ffoodwebr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flewinfox%2Ffoodwebr/lists"}