Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Demo of roxy tools #6

Merged
merged 6 commits into from
Feb 13, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,19 @@ Suggests:
httr,
knitr,
shinytest,
testthat (>= 2.0)
testthat (>= 2.0),
roxytypes,
roxylint
Remotes:
dgkf/roxytypes,
dgkf marked this conversation as resolved.
Show resolved Hide resolved
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
29 changes: 17 additions & 12 deletions R/generate_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -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.
numbersman77 marked this conversation as resolved.
Show resolved Hide resolved
#' @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:
numbersman77 marked this conversation as resolved.
Show resolved Hide resolved
#' - `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)
Expand Down
8 changes: 5 additions & 3 deletions R/hello.R
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down
31 changes: 20 additions & 11 deletions R/inc_prop.R
Original file line number Diff line number Diff line change
@@ -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:
dgkf marked this conversation as resolved.
Show resolved Hide resolved
#' - `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,
Expand Down
5 changes: 3 additions & 2 deletions man/generate_data.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/hello.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 14 additions & 5 deletions man/inc_prop.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions man/roxygen/meta.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
list(
markdown = TRUE,
packages = c(
"roxylint",
"roxytypes"
),
roclets = c(
"namespace",
"rd",
"roxylint::roxylint"
)
)
13 changes: 13 additions & 0 deletions man/roxylint/meta.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
list(
linters = list(
typed = list(
"descriptions should start lowercase" = "^[^[:upper:]]",
roxylint::lint_full_stop,
NULL # disallow registration of package defaults
),
numbersman77 marked this conversation as resolved.
Show resolved Hide resolved
param = list(
"descriptions should start lowercase" = "^[^[:upper:]]",
roxylint::lint_full_stop
)
)
)
5 changes: 5 additions & 0 deletions man/roxytypes/meta.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
list(
format = function(x, name, type, default, description, ...) {
glue::glue("(`{type}`)\\cr {description}")
numbersman77 marked this conversation as resolved.
Show resolved Hide resolved
}
)