mypackage
hello.R
hello.R
in mypackage
should contain thehello
function definition, documented with Roxygen documentation.
#' Hello World!
#'
#' Print personalised hello greeting from me.
#'
#' @param name character string. Your name!
#'
#' @return prints hello greeting to console
#' @export
#'
#' @examples
#' hello()
#' hello("Lucy Elen")
<- function(name = NULL) {
hello
# create greeting
if(is.null(name)){name <- "world"}
<- paste("Hello", name, "from Anna!")
greeting
# randomly sample an animal
<- names(cowsay::animals)
animal_names <- sample(1:length(animal_names), 1)
i
::say(greeting, animal_names[i])
cowsay
}
<!--chapter:end:09f_mypackage_hello.Rmd-->
# `mypackage` `test-hello.R`
`test-hello.R` in `mypackage` should contain the test for the `hello` function.
test_that("hello works", {
expect_null(suppressMessages(hello()))
})