changer: Change Name of Existing R Package

Description Usage Arguments Details Examples

View source: R/changer.R

Description

Changing the name of an existing R package is annoying but common task especially in the early stages of package development. Function changer tries to automate this task. See README for more information.

Usage

1
2
changer(path, new_name, check_validity = TRUE, change_git = TRUE,
  run_roxygen = FALSE, remote_name = NULL, ask = TRUE)

Arguments

path

Path of the package.

new_name

Desired name of the package.

check_validity

Check first if the package name is valid and available by running the function available from the package available Default is TRUE.

change_git

If TRUE (default), changes the remote url of the remote. Note that you still need to change the name of the GitHub repository manually as follows: Go to the URL of your Github package, click Settings, change the name under "Repository name", and click Rename.

run_roxygen

Should the package documentation be updated via roxygen? If TRUE, removes all old Rd files in man directory.

remote_name

Name of the remote. Defaults to git2r::remotes(repo)[1].

ask

Ask confirmation before starting the rename process. Default is TRUE.

Details

Note that if the package is already published in CRAN, then the name change is more problematic (you need to ask CRAN for permission first).

If the package is also available in Github, then you need to do the following:

Go to the URL of your Github package, click Settings near the top-right, change the name under "Repository name", and finally click Rename.

Warnings:

If the current name of your package is just some commonly used word (such as "package"), then you are in trouble, as find and replace will change all of those words to new_name as well.

If you have a function with same name as your package, that will change as well.

It is strongly recommended to have a backup backup before proceeding.

Inspired by Nick Tierney's blog post: https://www.njtierney.com/post/2017/10/27/change-pkg-name/

Examples

1
2
3
4
5
6
7
8
content <- letters
package.skeleton("package.with.boring.name", path = tempdir())
readLines(file.path(tempdir(), "package.with.boring.name", "DESCRIPTION"))

changer(file.path(tempdir(), "package.with.boring.name"), 
  new_name = "superpack", check_validity = FALSE, ask = FALSE)
readLines(file.path(tempdir(), "superpack", "DESCRIPTION"))
unlink(file.path(tempdir(), "superpack"), recursive = TRUE)

helske/changer documentation built on Feb. 21, 2020, 11:09 p.m.