I built this foo package for STAT 547 course practice. This practise is to fulfil the requirement of homework 08 of this course.
Here's how to use the
foo package.There are two function contained in the package.
The first function string_bindis to bind two string characters into one string with ethier unique values (defaults) or duplicated values. Based on the unit test result, this function works on any characters but with some exception. See notation in testthat.R for detail.
library(foo) string_bind("abc","bcde",method = "UNIQUE")
For the "duplicated" method, this function returns duplicated letters and the length of the returned value depends on how many times the letters are duplicated.
For example, inputs:" abb","bbc", method="duplicated"; outputs: "bbb" (letter b duplicated three times)
The second function letter_order is to reorder input letter in an alphabetical order (default) or a counter-alphabetical order.Based on the unit test resutls, the function cannot handle white space, and letters with mixed capitalization very well. See examples in testthat.R
library(foo) letter_order("A,Z,U,O",normal.sort = TRUE)
Here is a description of the work flow:
I wrote the two functions first with default arguments and optional arguments, inserted roxygen and used "load_all()" to complete the "build and load" process. I ran check() to conduct a preliminary check. Then I used document() to document the function. After that, I designed the three unit test using testthat package in "devtools". I ran the test() to make sure they are correctly written and there was no errors. Then I did a final check() to make sure it pass and updated the DESCRIPTION file. Finally, this README file was written. A vignettes file was generated. I committed each step, and pulled and pushed to my public GitHub Repo AriaGuo/r-package-practise at the end.