{attachment} is on CRAN !
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
We are pleased to announce that our package {attachment} is now available on CRAN. 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.
Deal with dependencies during package development
If you ever had the following error when checking your package, {attachment} is for you:
R CMD check results 1 error | 0 warnings | 0 notes checking package dependencies … ERROR Namespace dependency not required: ‘collateral’
With this error, Colin would answer you:
Indeed, the steps to deal with dependencies in your R functions when creating a package are:
- Use
package::function
directly in the code or list the function in the {roxygen2} header with@importFrom package function
- Run
devtools::document()
so thatfunction
appears in the NAMESPACE file - Add the {package} in the list of
Depends
in the DESCRIPTION file
Also as you create a vignette and tests in your package, you need to remember to list packages in the Suggests
section of your DESCRIPTION file
{attachment} is here to help
Package {attachment} will do all the above steps for you.
Install the package from CRAN or from Github:
# From CRAN install.packages("attachment") # From github remotes::install_github("ThinkR-open/attachment")
If you correctly called the package dependencies in the {roxygen2} skeleton, in your functions, in your Rmarkdown vignettes and in your tests, you only need to run attachment::att_to_description()
just before devtools::check()
. And that’s it, there is nothing else to remember !
Use {attachment} out of package development
{attachment} parses code of R scripts and Rmd. It lists all packages required to run that code. If you want to install all packages before trying to run the code of somebody else, you can use:
attachment::att_from_rmds(path = ".") %>% attachment::install_if_missing() attachment::att_from_rscripts(path = ".") %>% attachment::install_if_missing()
Also, if you build packages or Shiny Apps in packages for your delivery to your customers, or if you have to install your R product on customers’ servers, you will need to install all required packages before installation. A good start is to use a R script that lists all packages required. With function attachment::create_dependencies_file()
, you can build this kind of script:
# 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)) install.packages(i) } }
Documentation and participation
To read the full documentation of package {attachment}, you can follow this link to the {pkgodwn} site.
If you want to participate to the development, report bugs or propose pull requests, you will find the github page here.
Find our other contributions to open-source and the R community here.
The post {attachment} is on CRAN ! appeared first on (en) The R Task Force.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.