{"id":14067986,"url":"https://github.com/rich-iannone/pkgattrs","last_synced_at":"2025-10-22T02:56:44.243Z","repository":{"id":73928064,"uuid":"124416970","full_name":"rich-iannone/pkgattrs","owner":"rich-iannone","description":"Get information on the contents of one or more R packages","archived":false,"fork":false,"pushed_at":"2021-07-07T01:46:13.000Z","size":1455,"stargazers_count":21,"open_issues_count":2,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-24T06:02:23.415Z","etag":null,"topics":["api-explorer","function-graph","metadata-extractor","r-packages"],"latest_commit_sha":null,"homepage":"https://rich-iannone.github.io/pkgattrs/","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/rich-iannone.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2018-03-08T16:17:15.000Z","updated_at":"2023-10-27T16:23:38.000Z","dependencies_parsed_at":"2023-07-02T00:16:09.393Z","dependency_job_id":null,"html_url":"https://github.com/rich-iannone/pkgattrs","commit_stats":{"total_commits":154,"total_committers":1,"mean_commits":154.0,"dds":0.0,"last_synced_commit":"9258ad8cd457137b3397451682c7898281f28c08"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rich-iannone/pkgattrs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rich-iannone%2Fpkgattrs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rich-iannone%2Fpkgattrs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rich-iannone%2Fpkgattrs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rich-iannone%2Fpkgattrs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rich-iannone","download_url":"https://codeload.github.com/rich-iannone/pkgattrs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rich-iannone%2Fpkgattrs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280370895,"owners_count":26319317,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-22T02:00:06.515Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["api-explorer","function-graph","metadata-extractor","r-packages"],"created_at":"2024-08-13T07:05:52.992Z","updated_at":"2025-10-22T02:56:44.217Z","avatar_url":"https://github.com/rich-iannone.png","language":"R","funding_links":[],"categories":["R"],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r setup, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\n```\n\n[![CRAN status](https://www.r-pkg.org/badges/version/pkgattrs)](https://cran.r-project.org/package=pkgattrs)\n[![Travis build status](https://travis-ci.org/rich-iannone/pkgattrs.svg?branch=master)](https://travis-ci.org/rich-iannone/pkgattrs)\n[![AppVeyor build status](https://ci.appveyor.com/api/projects/status/github/rich-iannone/pkgattrs?branch=master\u0026svg=true)](https://ci.appveyor.com/project/rich-iannone/pkgattrs)\n\n```{r packages, message=FALSE, warning=FALSE, include=FALSE}\nlibrary(pkgattrs)\nlibrary(tidyverse)\n```\n\n# pkgattrs\n\nThe **pkgattrs** package is useful for getting information on the contents of any R package. One of the things that can be done is generating a summary of functions available in one or more packages. We can conveniently do this using the `pkgattrs()` function. Here is an example where we can create an informative table of the functions in the `pkgattrs` and `blastula` packages (hosted on GitHub).\n\n```{r echo=TRUE, results=\"hide\"}\nfn_info \u003c-\n  pkgattrs(\n    from_github(\"rich-iannone/pkgattrs\"),\n    from_github(\"rich-iannone/blastula\")\n  )\n```\n\nThe resulting tibble contains the following information in each record:\n\n- the package name (`pkg_name`)\n- the package source location (`pkg_src`)\n- the function name (`fn_name`)\n- whether the function is exported or not (`exported`)\n- the file that contains the function (`r_file`)\n- the relative path from pkg root to `r_file` (`r_file_path`) \n- the line number in `r_file` where the function starts (`ln_start`) and ends (`ln_end`)\n- the number of lines used for the function (`fn_lines`)\n- the number of lines in the function used for code (`code`), for comments (`comment`), and for roxygen statements (`roxygen`), and, the `fn_lines` lines that are blank (`blank`): the sum of all these is given in `total_lines`\n- optionally, the cyclomatic complexity of the function (`cyclocomp`)\n- the name of the package repository, if it was obtained from one (`pkg_repo`)\n- the name of the package path, if it was a locally-available package (`pkg_path`)\n- the number of package functions that are called in `fn_name` (`n_pkg_fns_called`)\n- a list column with the names of the package functions called in `fn_name` (`pkg_fns_called`)\n\n```{r}\nfn_info\n```\n\nThe package also supplies functions for visualizing the relationships between a package's functions as a network graph. For example, we could obtain a function information tibble for the **stationary** package, transform that to a graph, and then examine this network with the `function_graph_all()` function.\n\n```{r eval=FALSE}\npkgattrs(from_github(\"rich-iannone/stationary\")) %\u003e%\n  function_graph_all()\n```\n\n\u003cimg src=\"man/figures/stationary_graph_all.png\"\u003e\n\nIn this graph, the green nodes show the functions that are exported, and, the relative sizing of nodes is scaled the number of package functions called by each. Each edge represents the relationship `called_in`.\n\nWe can also focus on a subgraph with a single function. The function `function_graph_single()` can be used with the function graph object, taking a function name to show all the package functions that the function calls. In the following example, we can examine which functions are called by the `print.ptblank_agent()` method.\n\n```{r eval=FALSE}\npkgattrs(from_github(\"rich-iannone/pointblank\")) %\u003e%\n  function_graph_single(target_fn = \"print.ptblank_agent\")\n```\n\n\u003cimg src=\"man/figures/pointblank_graph_single.png\"\u003e\n\nFinally, the package has a means to write out a given package's API with the `write_pkg_api()` function. For the **pkgattrs** package (this package), we can generate a file that lists the exported functions along with each of the function arguments and default values.\n\n```{r eval=FALSE}\nwrite_pkg_api(filename = \"pkg_api\")\n```\n\nThis example generates the following text in the `API` file:\n\n```\nfrom_github(repo)\nfunction_graph_all(pkgattrs_tbl, pkg_name = NULL)\nfunction_graph_single(pkgattrs_tbl, target_fn, pkg_name = NULL)\npkg_api(...)\npkgattrs(..., .make_clean = TRUE, .get_cyclocomp = FALSE)\nwrite_pkg_api(..., filename = \"pkg_api\")\n```\n\n## Installation\n\nYou can install **pkgattrs** from GitHub with:\n\n```{r gh-installation, eval = FALSE}\ndevtools::install_github(\"rich-iannone/pkgattrs\")\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frich-iannone%2Fpkgattrs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frich-iannone%2Fpkgattrs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frich-iannone%2Fpkgattrs/lists"}