proportion_of_values_in_vector: Proportion of given values in a vector

View source: R/proportion_of_values_in_vector.R

proportion_of_values_in_vectorR Documentation

Proportion of given values in a vector

Description

Proportion of given values in a vector

Usage

proportion_of_values_in_vector(
  values = NULL,
  vector = NULL,
  na.exclude = TRUE,
  output_type = "proportion",
  silent = FALSE,
  conf.level = 0.95,
  correct_yates = TRUE
)

Arguments

values

a set of values that will count as successes (hits)

vector

a numeric or character vector containing successes (hits) and failures (misses)

na.exclude

if TRUE, NA values will be removed both from vector and values before calculation (default = TRUE).

output_type

By default, output_type = "proportion". If output_type = "proportion", the function will return the calculated proportion; if output_type = "se", the function will return the standard error of the sample proportion; if output_type = "dt", the function will return the the data table of proportion and confidence intervals.

silent

If silent = TRUE, no message will be printed regarding number of NA values or confidence interval. (default = FALSE)

conf.level

confidence level of the returned confidence interval. Input to this argument will be passed onto the conf.level argument in the prop.test function from the default stats package.

correct_yates

a logical indicating whether Yates' continuity correction should be applied where possible (default = TRUE). Input to this argument will be passed onto the correct argument in the prop.test function from the default stats package.

Examples

proportion_of_values_in_vector(
  values = 2:3, vector = c(rep(1:3, each = 10), rep(NA, 10))
)
proportion_of_values_in_vector(
  values = 2:3, vector = c(rep(1:3, each = 10), rep(NA, 10)),
  output_type = "se"
)
proportion_of_values_in_vector(
  values = 2:3, vector = c(rep(1:3, each = 10), rep(NA, 10)),
  conf.level = 0.99
)
proportion_of_values_in_vector(
  values = c(2:3, NA), vector = c(rep(1:3, each = 10), rep(NA, 10)),
  na.exclude = FALSE
)

kim documentation built on Oct. 9, 2023, 5:08 p.m.