pkgmkr aims to simplify the process of creating R packages by providing a single, straightforward function. It is designed to be user-friendly and to handle various package configurations, including optional Git integration, license selection, and more.
- Easy-to-use function for package creation
- Optional Git repository initialization
- Customizable package metadata
- License selection (MIT or GPL-3)
- README and
pkgdownsite generation - Configuration file support (YAML/JSON)
- Comprehensive input validation and error handling
In the future, you will be able to install the released version of pkgmkr from CRAN with:
install.packages("pkgmkr")Currently, pkgmkr can only be installed using devtools.
if (!requireNamespace("devtools", quietly = TRUE)) {
install.packages("devtools")
}
# Install pkgmkr from GitHub
devtools::install_github("sdhutchins/pkgmkr")Create a new R package with essential features:
library(pkgmkr)
# Create a simple package
mk_pkg(
path = "mypackage",
author = "Jane Doe",
email = "jane.doe@example.com",
git = FALSE,
readme_md = TRUE,
check_pkg_name = TRUE,
license = "MIT",
pkgdown = FALSE
)Create a package with Git repository and GitHub integration:
library(pkgmkr)
mk_pkg(
path = "~/projects/myawesomepackage",
author = "John Smith",
email = "john.smith@example.com",
git = TRUE,
git_username = "johnsmith",
git_email = "john.smith@example.com",
readme_md = TRUE,
check_pkg_name = TRUE,
license = "GPL-3",
pkgdown = TRUE
)You can also create packages from a YAML or JSON configuration file:
library(pkgmkr)
# Create a configuration file
config <- list(
pkg_name = "mypackage",
first_name = "Jane",
last_name = "Doe",
email = "jane.doe@example.com",
readme_md = TRUE,
git = FALSE,
check_pkg_name = TRUE,
license = "MIT",
pkgdown = FALSE
)
# Write the configuration
write_config("my_package_config.yaml", config)
# Create package from configuration
mk_pkg_from_config("my_package_config.yaml", file_type = "yaml")path: Path where the package will be created (can be just a package name or full path)author: Full name of the package author (e.g., "Jane Doe")email: Email address of the authorgit: Logical; whether to initialize a Git repository (default:TRUE)git_username: Git username for repository configurationgit_email: Git email for repository configurationreadme_md: Logical; whether to create a README.md file (default:TRUE)check_pkg_name: Logical; whether to check package name availability on CRAN (default:TRUE)license: License type - either "MIT" or "GPL-3" (default: "MIT")pkgdown: Logical; whether to set up and build pkgdown documentation site (default:TRUE)
pkgmkr includes comprehensive input validation to help you avoid common mistakes:
- Package names must start with a letter and contain only letters, numbers, and dots
- Email addresses must be properly formatted
- Author names must include at least a first and last name
- The package directory must not already exist
- License must be either "MIT" or "GPL-3"
All validation errors provide clear, helpful messages to guide you in fixing the issue.
Contributions are welcome! Please read the CONTRIBUTING.md for guidelines on how to contribute to this project.