Changing the name of an existing R package is annoying but common task in the early stages of package development (at least for me). Package changer
tries to automate this task:
-
Validity and availability of the new package name is checked by using
available
from available). -
All complete words matching the package name are replaced in all R scripts, C/C++/Fortran/Stan source codes, markdown files, and typical files in R packages, i.e. files with extension
.R
,.cpp
,.c
,.h
,.f
,.f90
,.f95
,.stan
,.md
,.Rmd
,.Rnw
,.html
,.yaml
,.yml
, and.bib
, as well as filesDESCRIPTION
,NAMESPACE
inst/CITATION
,.Rbuildignore
, andgitignore
. -
Change file names containing the package name. Only checks files with extensions listed above, as well as files
[oldname].Rproj
,[oldname]-package.R
,[oldname]-defunct.R
, and[oldname]-deprecated.R
. -
If
run_roxygen
isTRUE
(default), oldRd
files are removed. -
All files with extensions
.o
,.so
, and.dll
in/src
are removed to force a rebuild of the package. -
Name of the package directory is changed.
-
If
change_git
isTRUE
(default), the remote url of the git repository is changed to match the new name. Note that you still need to change the name of the repository in Github/Bitbucket etc manually. For example in Github: Go to the URL of your Github package, click Settings near the top-right, change the name under Repository name, and click Rename. -
If
run_roxygen
isTRUE
, update documentation and rebuild package.
Inspired by back-and-forth naming of the package particlefield) and Nick Tierney's blog post.
-
If the package is already published in CRAN, then you should first consult folks at CRAN whether they will accept the name change.
-
It is strongly recommended to have a backup backup before proceeding.
-
Note that if the old package name is a common word, it will be replaced in the docs etc as well!
You can install the developed version of changer from Github with:
devtools::install_github("helske/changer")
There is just one function in the package:
changer("../mypackagewithlongandboringname", "Rbitary")
- Fixed a major bug, now actually replaces the package name in the
.R
files! - With additional argument
replace_all
you can now replace also partial matches instead of just the whole word matches.
changer
now tests that the supplied path actually contains an R package by checking the existence of theDESCRIPTION
file.- yaml files are also checked, and warning is given regarding the rda files, thanks to Mahmoud Ahmed.