autoimport
A toolbox to automatically generate @importFrom roxygen tags from R files.
Science Score: 26.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (17.0%) to scientific vocabulary
Keywords from Contributors
Repository
A toolbox to automatically generate @importFrom roxygen tags from R files.
Basic Info
- Host: GitHub
- Owner: DanChaltiel
- Language: R
- Default Branch: main
- Homepage: https://danchaltiel.github.io/autoimport/
- Size: 27.5 MB
Statistics
- Stars: 19
- Watchers: 2
- Forks: 2
- Open Issues: 4
- Releases: 0
Metadata Files
README.md
autoimport 
autoimport is a package designed to easily add @importFrom roxygen tags to all your functions.
Concept
When importing functions into a package, the R Packages (2e) guidelines recommend using @importFrom, either above each function or in a dedicated section of the package-level documentation.
But let's be honest for a second, this is one of the most tedious tasks ever, isn't it? And we are devs, we love automating things, don't we?
Meet autoimport!
It parses your code, detects all imported functions, and adds the appropriate @importFrom tags in the right place. Just like that!
Installation
Install either from the stable version from CRAN or the dev version from GitHub:
``` r
Install from CRAN
pak::pak("autoimport")
Install from Github
pak::pak("DanChaltiel/autoimport") ```
Getting started
Just run the function, it's showtime!
``` r devtools::load_all(".") autoimport::autoimport() #location="function" by default
autoimport::autoimport(location="package")
```
The first run might take some time, but a cache system is implemented so that next runs are faster.
Afterward, you can see the diff and accept the changes using the shiny widget:
r
autoimport::import_review()
However, a picture is worth a thousand words:

As you could probably tell, the shiny widget is ~~stolen from~~ inspired by testthat::snapshot_review(). Many thanks for them for this gem!
Important notes
autoimportwill guess the potential source of your functions based on (1) the packages currently loaded in your environment (e.g. vialibrary()), and (2) the packages listed as dependencies in DESCRIPTION.load_all(".")is required for autoimport to have access to the package's private functions, for example so thatdplyr::filter()cannot maskyourpackage:::filter().Some package guesses are bound to be wrong, in which case you should use
usethis::use_import_from(). See "Limitations" below for more details.
Limitations
Autoimport is based on utils::getSrcref() and share the same limits. Therefore, some function syntaxes are not recognized and autoimport will try to remove their @importFrom from individual functions:
- Operators (
@importFrom dplyr %>%,@importFrom rlang :=, ...) - Functions called by name (e.g.
sapply(x, my_fun)) - Functions used inside strings (e.g.
glue("my_fun={my_fun(x)}"))
To keep them imported, you should either use a prefix (pkg::my_fun) or import them in your package-level documentation, as this file is ignored by default (due to ignore_package=TRUE).
For that, usethis::use_import_from() and usethis::use_pipe() are your friends!
Cache system
As running autoimport() on a large package can take some time, a cache system is implemented, by default in file inst/autoimport_cache.rds.
Any function not modified since last run should be taken from the cache, resulting on a much faster run.
In some seldom cases, this can cause issues with modifications in DESCRIPTION or IMPORTLIST not being taken into account. Run clean_cache() to remove this file, or use use_cache="write".
Algorithm
When trying to figure out which package to import a function from, autoimport() follows this algorithm:
- If the function is prefixed with the package, ignore
- Else, if the function is already mentioned in NAMESPACE, use the package
- Else, if the function is exported by only one package, use this package
- Else, ask the user from which package to import the function
- Else, warn that the function was not found
Note that this algorithm is still a bit experimental and that I could only test it on my few own packages. Any feedback is more than welcome!
Style
As I couldn't find any standardized guideline about the right order of roxygen2 tags (#30), autoimport puts them:
- in place of the first
@importFromtag if there is one - just before the function call otherwise
Owner
- Name: Dan Chaltiel
- Login: DanChaltiel
- Kind: user
- Location: France
- Company: @gustaveroussy
- Twitter: DanChaltiel
- Repositories: 4
- Profile: https://github.com/DanChaltiel
Data analyst (PharmD, PhD) and programming enthusiast. I love to code in R (tidyverse FTW!) but also in Kotlin/Java (Android), Python, PHP, JS, Arduino...
CodeMeta (codemeta.json)
{
"@context": "https://doi.org/10.5063/schema/codemeta-2.0",
"@type": "SoftwareSourceCode",
"identifier": "autoimport",
"description": "A toolbox to read all R files inside a package and automatically generate @importFrom 'roxygen2' tags in the right place. Includes a 'shiny' application to review the changes before applying them.",
"name": "autoimport: Automatic Generation of @importFrom Tags",
"relatedLink": "https://danchaltiel.github.io/autoimport/",
"codeRepository": "https://github.com/DanChaltiel/autoimport",
"issueTracker": "https://github.com/DanChaltiel/autoimport/issues",
"license": "https://spdx.org/licenses/GPL-3.0",
"version": "0.1.1",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
"url": "https://r-project.org"
},
"runtimePlatform": "R version 4.4.1 (2024-06-14 ucrt)",
"author": [
{
"@type": "Person",
"givenName": "Dan",
"familyName": "Chaltiel",
"email": "dan.chaltiel@gmail.com",
"@id": "https://orcid.org/0000-0003-3488-779X"
}
],
"maintainer": [
{
"@type": "Person",
"givenName": "Dan",
"familyName": "Chaltiel",
"email": "dan.chaltiel@gmail.com",
"@id": "https://orcid.org/0000-0003-3488-779X"
}
],
"softwareSuggestions": [
{
"@type": "SoftwareApplication",
"identifier": "callr",
"name": "callr",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=callr"
},
{
"@type": "SoftwareApplication",
"identifier": "covr",
"name": "covr",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=covr"
},
{
"@type": "SoftwareApplication",
"identifier": "devtools",
"name": "devtools",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=devtools"
},
{
"@type": "SoftwareApplication",
"identifier": "knitr",
"name": "knitr",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=knitr"
},
{
"@type": "SoftwareApplication",
"identifier": "pkgload",
"name": "pkgload",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=pkgload"
},
{
"@type": "SoftwareApplication",
"identifier": "rstudioapi",
"name": "rstudioapi",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=rstudioapi"
},
{
"@type": "SoftwareApplication",
"identifier": "testthat",
"name": "testthat",
"version": ">= 3.0.0",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=testthat"
},
{
"@type": "SoftwareApplication",
"identifier": "tidyverse",
"name": "tidyverse",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=tidyverse"
}
],
"softwareRequirements": {
"1": {
"@type": "SoftwareApplication",
"identifier": "R",
"name": "R",
"version": ">= 3.6.0"
},
"2": {
"@type": "SoftwareApplication",
"identifier": "cli",
"name": "cli",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=cli"
},
"3": {
"@type": "SoftwareApplication",
"identifier": "desc",
"name": "desc",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=desc"
},
"4": {
"@type": "SoftwareApplication",
"identifier": "diffviewer",
"name": "diffviewer",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=diffviewer"
},
"5": {
"@type": "SoftwareApplication",
"identifier": "digest",
"name": "digest",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=digest"
},
"6": {
"@type": "SoftwareApplication",
"identifier": "dplyr",
"name": "dplyr",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=dplyr"
},
"7": {
"@type": "SoftwareApplication",
"identifier": "fs",
"name": "fs",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=fs"
},
"8": {
"@type": "SoftwareApplication",
"identifier": "glue",
"name": "glue",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=glue"
},
"9": {
"@type": "SoftwareApplication",
"identifier": "purrr",
"name": "purrr",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=purrr"
},
"10": {
"@type": "SoftwareApplication",
"identifier": "readr",
"name": "readr",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=readr"
},
"11": {
"@type": "SoftwareApplication",
"identifier": "rlang",
"name": "rlang",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=rlang"
},
"12": {
"@type": "SoftwareApplication",
"identifier": "shiny",
"name": "shiny",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=shiny"
},
"13": {
"@type": "SoftwareApplication",
"identifier": "stringr",
"name": "stringr",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=stringr"
},
"14": {
"@type": "SoftwareApplication",
"identifier": "tibble",
"name": "tibble",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=tibble"
},
"15": {
"@type": "SoftwareApplication",
"identifier": "tidyr",
"name": "tidyr",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=tidyr"
},
"16": {
"@type": "SoftwareApplication",
"identifier": "utils",
"name": "utils"
},
"SystemRequirements": null
},
"fileSize": "511.987KB",
"releaseNotes": "https://github.com/DanChaltiel/autoimport/blob/master/NEWS.md",
"readme": "https://github.com/DanChaltiel/autoimport/blob/main/README.md",
"contIntegration": "https://github.com/DanChaltiel/autoimport/actions/workflows/R-CMD-check.yaml",
"developmentStatus": "https://lifecycle.r-lib.org/articles/stages.html#stable"
}
GitHub Events
Total
- Issues event: 49
- Watch event: 13
- Issue comment event: 31
- Push event: 56
- Pull request event: 6
- Fork event: 1
- Create event: 12
Last Year
- Issues event: 49
- Watch event: 13
- Issue comment event: 31
- Push event: 56
- Pull request event: 6
- Fork event: 1
- Create event: 12
Committers
Last synced: 12 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Dan Chaltiel | 1****l | 162 |
| github-actions | 4****] | 9 |
| mischko | m****m@m****g | 2 |
| Cedric Midoux | c****x@i****r | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 10 months ago
All Time
- Total issues: 36
- Total pull requests: 6
- Average time to close issues: 3 months
- Average time to close pull requests: 2 months
- Total issue authors: 6
- Total pull request authors: 3
- Average comments per issue: 0.94
- Average comments per pull request: 0.67
- Merged pull requests: 6
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 27
- Pull requests: 5
- Average time to close issues: 21 days
- Average time to close pull requests: 5 days
- Issue authors: 5
- Pull request authors: 2
- Average comments per issue: 0.89
- Average comments per pull request: 0.4
- Merged pull requests: 5
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- DanChaltiel (24)
- abichat (3)
- mihem (3)
- cregouby (2)
- rsh52 (1)
- eli-daniels (1)
Pull Request Authors
- DanChaltiel (4)
- CedricMidoux (2)
- mihem (2)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- cran 217 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 1
- Total maintainers: 1
cran.r-project.org: autoimport
Automatic Generation of @importFrom Tags
- Homepage: https://github.com/DanChaltiel/autoimport
- Documentation: http://cran.r-project.org/web/packages/autoimport/autoimport.pdf
- License: GPL-3
-
Latest release: 0.1.1
published over 1 year ago