From df7497aff1eeb55f7c7b9d8ad542284818671676 Mon Sep 17 00:00:00 2001 From: dgkf <18220321+dgkf@users.noreply.github.com> Date: Fri, 3 Feb 2023 16:49:50 -0500 Subject: [PATCH 1/6] initial pass at using roxy tools --- DESCRIPTION | 11 +++++++++-- R/generate_data.R | 29 +++++++++++++++++------------ R/hello.R | 8 +++++--- R/inc_prop.R | 31 ++++++++++++++++++++----------- man/generate_data.Rd | 15 ++++++++------- man/hello.Rd | 4 ++-- man/inc_prop.Rd | 21 +++++++++++++++------ man/roxygen/meta.R | 12 ++++++++++++ man/roxylint/meta.R | 13 +++++++++++++ man/roxytypes/meta.R | 5 +++++ 10 files changed, 106 insertions(+), 43 deletions(-) create mode 100644 man/roxygen/meta.R create mode 100644 man/roxylint/meta.R create mode 100644 man/roxytypes/meta.R diff --git a/DESCRIPTION b/DESCRIPTION index f91f866..0d6ee4f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -21,12 +21,19 @@ Suggests: httr, knitr, shinytest, - testthat (>= 2.0) + testthat (>= 2.0), + roxytypes, + roxylint +Remotes: + roxytypes=github::dgkf/roxytypes, + roxylint=github::dgkf/roxylint, +Config/Needs/documentation: + roxytypes, + roxylint VignetteBuilder: knitr biocViews: Encoding: UTF-8 Language: en-US LazyData: true -Roxygen: list(markdown = TRUE) RoxygenNote: 7.2.3 diff --git a/R/generate_data.R b/R/generate_data.R index 521637a..06a2ca7 100644 --- a/R/generate_data.R +++ b/R/generate_data.R @@ -5,21 +5,26 @@ #' hazard for the competing event of death, and the hazard for the "soft" competing events. #' Censoring is uniform in the given range. #' -#' @param n (`count`)\cr number of patients. -#' @param cens (`numeric`)\cr minimum and maximum censoring time. -#' @param haz_ae (`number`)\cr constant hazard for AE. -#' @param haz_death (`number`)\cr constant hazard for death. -#' @param haz_soft (`number`)\cr constant hazard for soft competing event. +#' @typed n: count +#' number of patients. +#' @typed cens: numeric +#' minimum and maximum censoring time. +#' @typed haz_ae: number +#' constant hazard for AE. +#' @typed haz_death: number +#' constant hazard for death. +#' @typed haz_soft: number +#' constant hazard for soft competing event. #' -#' @return A `data.frame` with the following columns: -#' -#' - `id`: Patient ID. -#' - `time_to_event`: Time to the first AE, death or soft competing event. -#' - `type_of_event`: 0 for censored, 1 for AE, 2 for death, 3 for soft competing event. -#' - `cens`: Censoring time. +#' @typedreturn data.frame +#' a `data.frame` with the following columns: +#' - `id`: Patient ID. +#' - `time_to_event`: Time to the first AE, death or soft competing event. +#' - `type_of_event`: 0 for censored, 1 for AE, 2 for death, 3 for soft +#' competing event. +#' - `cens`: Censoring time. #' #' @export -#' #' @examples #' set.seed(123) #' generate_data(n = 5, cens = c(2, 5), haz_ae = 2, haz_death = 3, haz_soft = 5) diff --git a/R/hello.R b/R/hello.R index 58efee5..51740fe 100644 --- a/R/hello.R +++ b/R/hello.R @@ -2,11 +2,13 @@ #' #' @description Greet a person and appropriately capitalize their name. #' -#' @param name Your name (character string; e.g. "john doe"). +#' @typed name: string +#' a name, such as "john doe". #' -#' @return A character string, capitalized to title case. -#' @export +#' @typedreturn string +#' capitalized to title case. #' +#' @export #' @examples #' hello("james bond") hello <- function(name = "your name") { diff --git a/R/inc_prop.R b/R/inc_prop.R index ba2a95d..d630b8c 100644 --- a/R/inc_prop.R +++ b/R/inc_prop.R @@ -1,21 +1,30 @@ #' Computing the Incidence Proportion #' -#' @param data (`data.frame`)\cr with columns including -#' - `time_to_event`: Time to the first AE, death or soft competing event. -#' - `type_of_event`: 0 for censored, 1 for AE, 2 for death, 3 for soft competing event. +#' @typed data: data.frame +#' with columns including: +#' - `time_to_event`: Time to the first AE, death or soft competing +#' event. +#' - `type_of_event`: 0 for censored, 1 for AE, 2 for death, 3 for soft +#' competing event. +#' @typed tau: numeric +#' milestone at which incidence proportion is computed. #' -#' @param tau (`numeric`)\cr milestone at which incidence proportion is computed. -#' -#' @return A `vector` with the following entries: -#' -#' - `ae_prob`: Estimated probability of AE. -#' - `ae_prob_var`: Variance of that estimate. +#' @typedreturn vector +#' a vector with the following entries: +#' - `ae_prob`: Estimated probability of AE. +#' - `ae_prob_var`: Variance of that estimate. #' #' @export -#' #' @examples #' set.seed(123) -#' dat <- generate_data(n = 5, cens = c(2, 5), haz_ae = 2, haz_death = 3, haz_soft = 5) +#' dat <- generate_data( +#' n = 5, +#' cens = c(2, 5), +#' haz_ae = 2, +#' haz_death = 3, +#' haz_soft = 5 +#' ) +#' #' inc_prop(dat, tau = 4) #' inc_prop <- function(data, diff --git a/man/generate_data.Rd b/man/generate_data.Rd index 4094c4e..c4d8b64 100644 --- a/man/generate_data.Rd +++ b/man/generate_data.Rd @@ -7,22 +7,23 @@ generate_data(n, cens, haz_ae, haz_death, haz_soft) } \arguments{ -\item{n}{(\code{count})\cr number of patients.} +\item{n}{(`count`)\cr number of patients.} -\item{cens}{(\code{numeric})\cr minimum and maximum censoring time.} +\item{cens}{(`numeric`)\cr minimum and maximum censoring time.} -\item{haz_ae}{(\code{number})\cr constant hazard for AE.} +\item{haz_ae}{(`number`)\cr constant hazard for AE.} -\item{haz_death}{(\code{number})\cr constant hazard for death.} +\item{haz_death}{(`number`)\cr constant hazard for death.} -\item{haz_soft}{(\code{number})\cr constant hazard for soft competing event.} +\item{haz_soft}{(`number`)\cr constant hazard for soft competing event.} } \value{ -A \code{data.frame} with the following columns: +(`data.frame`)\cr a \code{data.frame} with the following columns: \itemize{ \item \code{id}: Patient ID. \item \code{time_to_event}: Time to the first AE, death or soft competing event. -\item \code{type_of_event}: 0 for censored, 1 for AE, 2 for death, 3 for soft competing event. +\item \code{type_of_event}: 0 for censored, 1 for AE, 2 for death, 3 for soft +competing event. \item \code{cens}: Censoring time. } } diff --git a/man/hello.Rd b/man/hello.Rd index e7eb880..ca21811 100644 --- a/man/hello.Rd +++ b/man/hello.Rd @@ -7,10 +7,10 @@ hello(name = "your name") } \arguments{ -\item{name}{Your name (character string; e.g. "john doe").} +\item{name}{(`string`)\cr a name, such as "john doe".} } \value{ -A character string, capitalized to title case. +(`string`)\cr capitalized to title case. } \description{ Greet a person and appropriately capitalize their name. diff --git a/man/inc_prop.Rd b/man/inc_prop.Rd index d0967d0..e8e8707 100644 --- a/man/inc_prop.Rd +++ b/man/inc_prop.Rd @@ -7,16 +7,18 @@ inc_prop(data, tau) } \arguments{ -\item{data}{(\code{data.frame})\cr with columns including +\item{data}{(`data.frame`)\cr with columns including: \itemize{ -\item \code{time_to_event}: Time to the first AE, death or soft competing event. -\item \code{type_of_event}: 0 for censored, 1 for AE, 2 for death, 3 for soft competing event. +\item \code{time_to_event}: Time to the first AE, death or soft competing +event. +\item \code{type_of_event}: 0 for censored, 1 for AE, 2 for death, 3 for soft +competing event. }} -\item{tau}{(\code{numeric})\cr milestone at which incidence proportion is computed.} +\item{tau}{(`numeric`)\cr milestone at which incidence proportion is computed.} } \value{ -A \code{vector} with the following entries: +(`vector`)\cr a vector with the following entries: \itemize{ \item \code{ae_prob}: Estimated probability of AE. \item \code{ae_prob_var}: Variance of that estimate. @@ -27,7 +29,14 @@ Computing the Incidence Proportion } \examples{ set.seed(123) -dat <- generate_data(n = 5, cens = c(2, 5), haz_ae = 2, haz_death = 3, haz_soft = 5) +dat <- generate_data( + n = 5, + cens = c(2, 5), + haz_ae = 2, + haz_death = 3, + haz_soft = 5 +) + inc_prop(dat, tau = 4) } diff --git a/man/roxygen/meta.R b/man/roxygen/meta.R new file mode 100644 index 0000000..8c6a99c --- /dev/null +++ b/man/roxygen/meta.R @@ -0,0 +1,12 @@ +list( + markdown = TRUE, + packages = c( + "roxylint", + "roxytypes" + ), + roclets = c( + "namespace", + "rd", + "roxylint::roxylint" + ) +) diff --git a/man/roxylint/meta.R b/man/roxylint/meta.R new file mode 100644 index 0000000..88eef4a --- /dev/null +++ b/man/roxylint/meta.R @@ -0,0 +1,13 @@ +list( + linters = list( + typed = list( + "descriptions should start lowercase" = "^[^[:upper:]]", + roxylint::lint_full_stop, + NULL # disallow registration of package defaults + ), + param = list( + "descriptions should start lowercase" = "^[^[:upper:]]", + roxylint::lint_full_stop + ) + ) +) diff --git a/man/roxytypes/meta.R b/man/roxytypes/meta.R new file mode 100644 index 0000000..fd767f6 --- /dev/null +++ b/man/roxytypes/meta.R @@ -0,0 +1,5 @@ +list( + format = function(x, name, type, default, description, ...) { + glue::glue("(`{type}`)\\cr {description}") + } +) From 40cdc40765fa743a499b389dcfb12dbd3b3c1fc9 Mon Sep 17 00:00:00 2001 From: dgkf <18220321+dgkf@users.noreply.github.com> Date: Fri, 3 Feb 2023 17:45:12 -0500 Subject: [PATCH 2/6] using markdown update to regenerate docs --- DESCRIPTION | 4 ++-- man/generate_data.Rd | 12 ++++++------ man/hello.Rd | 4 ++-- man/inc_prop.Rd | 6 +++--- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 0d6ee4f..ae58129 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -25,8 +25,8 @@ Suggests: roxytypes, roxylint Remotes: - roxytypes=github::dgkf/roxytypes, - roxylint=github::dgkf/roxylint, + dgkf/roxytypes, + dgkf/roxylint, Config/Needs/documentation: roxytypes, roxylint diff --git a/man/generate_data.Rd b/man/generate_data.Rd index c4d8b64..18af5d9 100644 --- a/man/generate_data.Rd +++ b/man/generate_data.Rd @@ -7,18 +7,18 @@ generate_data(n, cens, haz_ae, haz_death, haz_soft) } \arguments{ -\item{n}{(`count`)\cr number of patients.} +\item{n}{(\code{count})\cr number of patients.} -\item{cens}{(`numeric`)\cr minimum and maximum censoring time.} +\item{cens}{(\code{numeric})\cr minimum and maximum censoring time.} -\item{haz_ae}{(`number`)\cr constant hazard for AE.} +\item{haz_ae}{(\code{number})\cr constant hazard for AE.} -\item{haz_death}{(`number`)\cr constant hazard for death.} +\item{haz_death}{(\code{number})\cr constant hazard for death.} -\item{haz_soft}{(`number`)\cr constant hazard for soft competing event.} +\item{haz_soft}{(\code{number})\cr constant hazard for soft competing event.} } \value{ -(`data.frame`)\cr a \code{data.frame} with the following columns: +(\code{data.frame})\cr a \code{data.frame} with the following columns: \itemize{ \item \code{id}: Patient ID. \item \code{time_to_event}: Time to the first AE, death or soft competing event. diff --git a/man/hello.Rd b/man/hello.Rd index ca21811..c1e57d0 100644 --- a/man/hello.Rd +++ b/man/hello.Rd @@ -7,10 +7,10 @@ hello(name = "your name") } \arguments{ -\item{name}{(`string`)\cr a name, such as "john doe".} +\item{name}{(\code{string})\cr a name, such as "john doe".} } \value{ -(`string`)\cr capitalized to title case. +(\code{string})\cr capitalized to title case. } \description{ Greet a person and appropriately capitalize their name. diff --git a/man/inc_prop.Rd b/man/inc_prop.Rd index e8e8707..c2d7236 100644 --- a/man/inc_prop.Rd +++ b/man/inc_prop.Rd @@ -7,7 +7,7 @@ inc_prop(data, tau) } \arguments{ -\item{data}{(`data.frame`)\cr with columns including: +\item{data}{(\code{data.frame})\cr with columns including: \itemize{ \item \code{time_to_event}: Time to the first AE, death or soft competing event. @@ -15,10 +15,10 @@ event. competing event. }} -\item{tau}{(`numeric`)\cr milestone at which incidence proportion is computed.} +\item{tau}{(\code{numeric})\cr milestone at which incidence proportion is computed.} } \value{ -(`vector`)\cr a vector with the following entries: +(\code{vector})\cr a vector with the following entries: \itemize{ \item \code{ae_prob}: Estimated probability of AE. \item \code{ae_prob_var}: Variance of that estimate. From e9a2d7548937ca24793d6fe37576e2b94a5f4cb7 Mon Sep 17 00:00:00 2001 From: dgkf <18220321+dgkf@users.noreply.github.com> Date: Mon, 13 Feb 2023 11:17:27 -0500 Subject: [PATCH 3/6] moving roxy remote urls to openpharma org --- DESCRIPTION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index ae58129..fdfc051 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -25,8 +25,8 @@ Suggests: roxytypes, roxylint Remotes: - dgkf/roxytypes, - dgkf/roxylint, + openpharma/roxytypes, + openpharma/roxylint, Config/Needs/documentation: roxytypes, roxylint From 6c4ed72ce28979a7144c0e45499672975c03978c Mon Sep 17 00:00:00 2001 From: dgkf <18220321+dgkf@users.noreply.github.com> Date: Mon, 13 Feb 2023 15:38:05 -0500 Subject: [PATCH 4/6] linting meta files --- man/roxygen/meta.R | 2 +- man/roxylint/meta.R | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/man/roxygen/meta.R b/man/roxygen/meta.R index 8c6a99c..133fb01 100644 --- a/man/roxygen/meta.R +++ b/man/roxygen/meta.R @@ -3,7 +3,7 @@ list( packages = c( "roxylint", "roxytypes" - ), + ), roclets = c( "namespace", "rd", diff --git a/man/roxylint/meta.R b/man/roxylint/meta.R index 88eef4a..6cf39e4 100644 --- a/man/roxylint/meta.R +++ b/man/roxylint/meta.R @@ -3,7 +3,7 @@ list( typed = list( "descriptions should start lowercase" = "^[^[:upper:]]", roxylint::lint_full_stop, - NULL # disallow registration of package defaults + NULL # disallow registration of package defaults ), param = list( "descriptions should start lowercase" = "^[^[:upper:]]", From 41b3ada01c9ebe33ad3b803feedb5733d1c0b0dc Mon Sep 17 00:00:00 2001 From: Doug Kelkhoff <18220321+dgkf@users.noreply.github.com> Date: Mon, 13 Feb 2023 15:44:05 -0500 Subject: [PATCH 5/6] Apply suggestions from code review Co-authored-by: Daniel Sabanes Bove --- R/inc_prop.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/inc_prop.R b/R/inc_prop.R index d630b8c..7b4c0fe 100644 --- a/R/inc_prop.R +++ b/R/inc_prop.R @@ -10,7 +10,7 @@ #' milestone at which incidence proportion is computed. #' #' @typedreturn vector -#' a vector with the following entries: +#' with the following entries: #' - `ae_prob`: Estimated probability of AE. #' - `ae_prob_var`: Variance of that estimate. #' From ff43913b6f9ec4dc984bf83db2390e24744f3659 Mon Sep 17 00:00:00 2001 From: dgkf <18220321+dgkf@users.noreply.github.com> Date: Mon, 13 Feb 2023 15:48:11 -0500 Subject: [PATCH 6/6] rebuilding docs --- R/hello.R | 2 +- man/inc_prop.Rd | 2 +- man/plumber_api.Rd | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/R/hello.R b/R/hello.R index 51740fe..e485612 100644 --- a/R/hello.R +++ b/R/hello.R @@ -48,7 +48,7 @@ shiny_app <- function() { #' @description Greet a person and appropriately capitalize their name #' as a Plumber API. #' -#' @param ... Additional arguments to plumber::pr_run() +#' @param ... Additional arguments to plumber::pr_run(). #' #' @return Plumber API showcasing the personal greeting feature. #' @export diff --git a/man/inc_prop.Rd b/man/inc_prop.Rd index c2d7236..62d954b 100644 --- a/man/inc_prop.Rd +++ b/man/inc_prop.Rd @@ -18,7 +18,7 @@ competing event. \item{tau}{(\code{numeric})\cr milestone at which incidence proportion is computed.} } \value{ -(\code{vector})\cr a vector with the following entries: +(\code{vector})\cr with the following entries: \itemize{ \item \code{ae_prob}: Estimated probability of AE. \item \code{ae_prob_var}: Variance of that estimate. diff --git a/man/plumber_api.Rd b/man/plumber_api.Rd index 84ef92b..ab96741 100644 --- a/man/plumber_api.Rd +++ b/man/plumber_api.Rd @@ -7,7 +7,7 @@ plumber_api(...) } \arguments{ -\item{...}{Additional arguments to plumber::pr_run()} +\item{...}{Additional arguments to plumber::pr_run().} } \value{ Plumber API showcasing the personal greeting feature.