h_count_cumulative: Helper function for 's_count_cumulative()'

View source: R/count_cumulative.R

h_count_cumulativeR Documentation

Helper function for s_count_cumulative()

Description

[Stable]

Helper function to calculate count and fraction of x values in the lower or upper tail given a threshold.

Usage

h_count_cumulative(
  x,
  threshold,
  lower_tail = TRUE,
  include_eq = TRUE,
  na.rm = TRUE,
  .N_col
)

Arguments

x

(numeric)
vector of numbers we want to analyze.

threshold

(numeric(1))
a cutoff value as threshold to count values of x.

lower_tail

(flag)
whether to count lower tail, default is TRUE.

include_eq

(flag)
whether to include value equal to the threshold in count, default is TRUE.

na.rm

(flag)
whether NA values should be removed from x prior to analysis.

.N_col

(integer(1))
column-wise N (column count) for the full column being analyzed that is typically passed by rtables.

Value

A named vector with items:

  • count: the count of values less than, less or equal to, greater than, or greater or equal to a threshold of user specification.

  • fraction: the fraction of the count.

See Also

count_cumulative

Examples

set.seed(1, kind = "Mersenne-Twister")
x <- c(sample(1:10, 10), NA)
.N_col <- length(x)

h_count_cumulative(x, 5, .N_col = .N_col)
h_count_cumulative(x, 5, lower_tail = FALSE, include_eq = FALSE, na.rm = FALSE, .N_col = .N_col)
h_count_cumulative(x, 0, lower_tail = FALSE, .N_col = .N_col)
h_count_cumulative(x, 100, lower_tail = FALSE, .N_col = .N_col)


tern documentation built on June 22, 2024, 10:25 a.m.