add_prop_test {tidytidbits}R Documentation

Add results of prop.test to data frame

Description

Adds prop.test results as columns to data frame based on data in columns For use with a tibble in a pipe: Using one-group prop.test, adds confidence intervals (with given conf.level) for the proportion of x positive results in n trials, and the p value that the proportion is equal to p (default: 0.5) (to add the estimated proportion itself, use count_by)

Usage

add_prop_test(
  .df,
  x,
  n,
  p = NULL,
  CI_lower_name = "CI_lower",
  CI_upper_name = "CI_upper",
  p_name = "p",
  alternative = c("two.sided", "less", "greater"),
  conf.level = 0.95,
  correct = TRUE
)

Arguments

.df

A data frame

x

The column/vector with the number of positive results

n

The column/vector/constant with the number of trials

p

Assumed proportion: Will add a p-value that the proportion is equal to p (default: 0.5)

CI_lower_name, CI_upper_name, p_name

Column names of the added columns

alternative, conf.level, correct

As for prop.test

Value

Data frame with columns added

See Also

count_by()

Examples

library(magrittr)
if (requireNamespace("survival", quietly = TRUE))
{
   survival::aml %>%
   count_by(x) %>%
   add_prop_test(n, sum(n), rel)
}

[Package tidytidbits version 0.3.2 Index]