From 8d0fbf71ecc613780fc47cc10a12cd95acd8a2bc Mon Sep 17 00:00:00 2001 From: tomyukn <5608467+tomyukn@users.noreply.github.com> Date: Sat, 19 Oct 2024 08:11:50 +0000 Subject: [PATCH] feat: #1839 create my_first_fcn --- NAMESPACE | 1 + NEWS.md | 1 + R/my_first_fcn.R | 16 ++++++++++++++++ man/list_tte_source_objects.Rd | 1 + man/my_first_fcn.Rd | 24 ++++++++++++++++++++++++ man/params.Rd | 3 ++- tests/testthat/test-my_first_fcn.R | 10 ++++++++++ 7 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 R/my_first_fcn.R create mode 100644 man/my_first_fcn.Rd create mode 100644 tests/testthat/test-my_first_fcn.R diff --git a/NAMESPACE b/NAMESPACE index 9bab92b1cf..47114d4e37 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -146,6 +146,7 @@ export(list_all_templates) export(list_tte_source_objects) export(max_cond) export(min_cond) +export(my_first_fcn) export(negate_vars) export(params) export(print_named_list) diff --git a/NEWS.md b/NEWS.md index 91fb0405c8..4e77cd6389 100644 --- a/NEWS.md +++ b/NEWS.md @@ -6,6 +6,7 @@ `AVALCATx` & `AVALCAxN`. (#2480) - New function `derive_vars_crit_flag()` for deriving criterion flag variables (`CRITy`, `CRITyFL`, `CRITyFLN`). (#2468) +- New function `my_first_fcn()` as dummy practice. (#1839) - Replace use of `data("sdtm")` with `sdtm <- pharmaverse::sdtm` in templates and vignettes. (#2498) diff --git a/R/my_first_fcn.R b/R/my_first_fcn.R new file mode 100644 index 0000000000..92ca566f12 --- /dev/null +++ b/R/my_first_fcn.R @@ -0,0 +1,16 @@ +#' Print a Greeting Message +#' +#' Prints a fixed greeting `message`. +#' +#' @return No return value (`NULL`). +#' +#' @keywords other_advanced +#' @family other_advanced +#' +#' @export +#' +#' @examples +#' my_first_fcn() +my_first_fcn <- function() { + message("Welcome to the admiral family!") +} diff --git a/man/list_tte_source_objects.Rd b/man/list_tte_source_objects.Rd index db624766b1..a6e310c726 100644 --- a/man/list_tte_source_objects.Rd +++ b/man/list_tte_source_objects.Rd @@ -21,6 +21,7 @@ list_tte_source_objects() } \seealso{ Other Advanced Functions: +\code{\link{my_first_fcn}()}, \code{\link{params}()} } \concept{other_advanced} diff --git a/man/my_first_fcn.Rd b/man/my_first_fcn.Rd new file mode 100644 index 0000000000..b6f8bc8f19 --- /dev/null +++ b/man/my_first_fcn.Rd @@ -0,0 +1,24 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/my_first_fcn.R +\name{my_first_fcn} +\alias{my_first_fcn} +\title{Print a Greeting Message} +\usage{ +my_first_fcn() +} +\value{ +No return value (\code{NULL}). +} +\description{ +Prints a fixed greeting \code{message}. +} +\examples{ +my_first_fcn() +} +\seealso{ +Other Advanced Functions: +\code{\link{list_tte_source_objects}()}, +\code{\link{params}()} +} +\concept{other_advanced} +\keyword{other_advanced} diff --git a/man/params.Rd b/man/params.Rd index ba41405a43..3e1c8b4176 100644 --- a/man/params.Rd +++ b/man/params.Rd @@ -100,7 +100,8 @@ call_derivation( \code{\link[=call_derivation]{call_derivation()}} Other Advanced Functions: -\code{\link{list_tte_source_objects}()} +\code{\link{list_tte_source_objects}()}, +\code{\link{my_first_fcn}()} } \concept{other_advanced} \keyword{other_advanced} diff --git a/tests/testthat/test-my_first_fcn.R b/tests/testthat/test-my_first_fcn.R new file mode 100644 index 0000000000..a851b7966e --- /dev/null +++ b/tests/testthat/test-my_first_fcn.R @@ -0,0 +1,10 @@ +# my_first_fcn ---- +## Test 1: returns NULL ---- +test_that("my_first_fcn Test 1: returns NULL", { + expect_null(my_first_fcn()) +}) + +## Test 2: produces a message ---- +test_that("my_first_fcn Test 2: produces a message", { + expect_message(my_first_fcn(), "^Welcome to the admiral family!\\n$") +})