valid_pkgname: Validate package and function names

View source: R/extension-utils.R

valid_pkgnameR Documentation

Validate package and function names

Description

Naming rule obtained from 'Writing R Extensions' manual. The corresponding regular expression used for verifying the package name is "[[:alpha:]][[:alnum:]\.]*[[:alnum:]]". For function names this is "((?:[[:alpha:]]|\.(?![0-9]))[[:alnum:]_\.]*)"

Usage

valid_pkgname(pkg)

valid_funcname(func)

Arguments

pkg

string vector containing package names. Can be a vector of strings with size of at least 1.

func

string vector containing function names. Can be a vector of strings with size of at least 1.

Value

A named logical indicating whether the package name is valid.

References

make.names, 'Writing R Extensions' manual.

See Also

Other developer functions: crossref_description(), generic_implementations(), load_packages(), update_settings()

Examples

valid_pkgname("hgutils") # valid
valid_pkgname("ggplot2") # valid
valid_pkgname("pkg2.-1") # invalid

valid_funcname(".hgutils") # valid
valid_funcname("ggplot2") # valid
valid_funcname(".2pkg") # invalid

hgutils documentation built on March 31, 2022, 5:06 p.m.