Learn R Programming

infer (version 0.5.2)

prop_test: Tidy proportion test

Description

A tidier version of prop.test() for equal or given proportions.

Usage

prop_test(
  x,
  formula,
  response = NULL,
  explanatory = NULL,
  p = NULL,
  order = NULL,
  alternative = "two-sided",
  conf_int = TRUE,
  conf_level = 0.95,
  ...
)

Arguments

x

A data frame that can be coerced into a tibble.

formula

A formula with the response variable on the left and the explanatory on the right, where an explanatory variable NULL indicates a test of a single proportion.

response

The variable name in x that will serve as the response. This is alternative to using the formula argument. This is an alternative to the formula interface.

explanatory

The variable name in x that will serve as the explanatory variable. Optional. This is an alternative to the formula interface.

p

A numeric vector giving the hypothesized null proportion of success for each group.

order

A string vector specifying the order in which the proportions should be subtracted, where order = c("first", "second") means "first" - "second". Ignored for one-sample tests, and optional for two sample tests.

alternative

Character string giving the direction of the alternative hypothesis. Options are "two-sided" (default), "greater", or "less".

conf_int

A logical value for whether to report the confidence interval or not. TRUE by default, ignored if p is specified for a two-sample test.

conf_level

A numeric value between 0 and 1. Default value is 0.95.

...

Additional arguments for prop.test().

Examples

Run this code
# NOT RUN {
# proportion test for difference in proportions of 
# college completion by respondent sex
prop_test(gss, 
          college ~ sex,  
          order = c("female", "male"))
          
# a one-proportion test for hypothesized null 
# proportion of college completion of .2
prop_test(gss,
          college ~ NULL,
          p = .2)

# }

Run the code above in your browser using DataLab