Shorten the r2resume package
Obinna Obianom
2022-12-10
Source:vignettes/simple_samples.Rmd
simple_samples.Rmd
The number of R packages created per month by users is increasing dramatically. When creating a package, authors may sometimes struggle with coming up with easy to remember function names, and at the same time hoping that other packages do not already have the same function names. In trying to meet this goal sometimes, function names are not descriptive enough and may confuse the potential users. The purpose of the r2shortcode package is to serve as a package function shortener and also provide shorthand names for other functions. Having this package will entice authors to create long function names without the fear of users not wanting to use their packages because of the long names. In a way, everyone wins - the authors can use long descriptive function names, and the users can use the r2shortcode to shorten the functions while still using the package in question.
Below is an example to demonstrate how the r2shortcode package can be used to shorten function names in a package called r2resume - main site or github site
Attach the r2shortcode package
First, attach the package shortener, r2shortcode package
library("r2shortcode")
#>
#> r2shortcodes: a package that shortens your other packages
#>
#> Attaching package: 'r2shortcode'
#> The following object is masked from 'package:utils':
#>
#> help
Call the shorten function to shorten the package
Second, call the shorten function to shorten a desired package already installed in your library
shortenPkg("r2resume",addPrefix = T)
#> Successfully shortened r2resume. To view the functions and their equivalence, enter index("r2resume")
# you may include more packages on a new line
List the shorthand functions and their matching functions
Thirdly, get a list of the created shorthand function names and their corresponding functions
index("r2resume")
#> Short Function Original Function
#> 1 r2r.g r2resume::generate
#> 2 r2r.gP r2resume::getPublication
#> 3 r2r.lE r2resume::loadExamples
#>
#> Use help(short-function-name) or whatis(short-function-name) to get the definitions.
Get help for a specific shorthand function
Forthly and alternatively, get the description for a specific shorthand function
help("r2.gP") #OR whatis("r2.gP")
#> No documentation for 'r2.gP' in specified packages and libraries:
#> you could try '??r2.gP'