Skip to content
Tools to deal with dependencies in scripts, Rmd and packages
Branch: master
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
R add package level documentation May 15, 2019
img Update vignette Aug 9, 2018
inst improve code coverage May 4, 2019
man add package level documentation May 15, 2019
tests improve code coverage May 4, 2019
vignettes path for external package in att_to_description Apr 2, 2019
.Rbuildignore fix appveyor. Depends R>3.3 Mar 9, 2019
.gitignore fix appveyor. Depends R>3.3 Mar 9, 2019
.travis.yml Parse tests directory May 4, 2019 init Jun 7, 2018
DESCRIPTION bump to 0.0.9 May 4, 2019
NAMESPACE add package level documentation May 15, 2019 Add encoding to att_from_rmd May 4, 2019
README.Rmd it's on CRAN ! May 6, 2019 it's on CRAN ! May 6, 2019
_pkgdown.yml Add codecov and update pkgdown template Mar 9, 2019
appveyor.yml fix appveyor. Depends R>3.3 Mar 9, 2019
attachment.Rproj Parse tests directory May 4, 2019
codecov.yml Add covr and testthat Jun 21, 2018
devstuff_history.R Parse tests directory May 4, 2019

Travis build status Build statusCoverage statusCRAN status


The goal of attachment is to help to deal with package dependencies during package development. It also gives useful tools to install or list missing packages used inside Rscripts or Rmds.

When building a package, we have to add @importFrom in our documentation or pkg::fun in the R code. The most important is not to forget to add the list of dependencies in the “Imports” or “Suggests” package lists in the DESCRIPTION file.

Why do you have to repeat twice the same thing ?
And what happens when you remove a dependency for one of your functions ? Do you really want to run a “Find in files” to verify that you do not need this package anymore ?

Let {attachment} help you ! This reads your NAMESPACE, your functions in R directory and your vignettes, then update the DESCRIPTION file accordingly. Are you ready to be lazy ?


# install.packages("devtools")

Use package {attachment}


What you really want is to fill and update your description file along with the modifications of your documentation. Indeed, only the following function will really be called. Use and abuse during the development of your package !


As {pkgdown} and {covr} are not listed in any script in your package, a common call for your development packages would be:

attachment::att_to_description(extra.suggests = c("pkgdown", "covr"))

To quickly install missing packages from a DESCRIPTION file, use:


To quickly install missing packages needed to compile Rmd files or run Rscripts, use:

attachment::att_from_rmds(path = ".") %>% attachment::install_if_missing()

attachment::att_from_rscripts(path = ".") %>% attachment::install_if_missing()

Function attachment::create_dependencies_file() will create a dependencies.R file in inst/ directory. This R script contains the procedure to quickly install missing dependencies:

# No Remotes ----
# remotes::install_github("ThinkR-open/fcuk")
# Attachments ----
to_install <- c("covr", "desc", "devtools", "glue", "knitr", "magrittr", "rmarkdown", "stats", "stringr", "testthat", "utils")
for (i in to_install) {
  message(paste("looking for ", i))
  if (!requireNamespace(i)) {
    message(paste("     installing", i))

Of course, you can also use {attachment} out of a package to list all package dependencies of R scripts using att_from_rscripts or Rmd files using att_from_rmds.

dummypackage <- system.file("dummypackage", package = "attachment")

att_from_rscripts(path = dummypackage)
att_from_rmds(path = file.path(dummypackage,"vignettes"))


Package {attachment} has a vignette to present the different functions available. There is also a recommandation to have a devstuff_history.R in the root directory of your package. (Have a look at devstuff_history.R in the present package)

vignette("fill-pkg-description", package = "attachment")

The vignette is available on the {pkgdown} page:

See full documentation realized using {pkgdown} at

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

You can’t perform that action at this time.