proptestfordf: Proportion Test for Two Groups in a DataFrame

View source: R/proptestfordf.R

proptestfordfR Documentation

Proportion Test for Two Groups in a DataFrame

Description

This function performs a proportion test between two specified groups in a given dataframe. It calculates the number of successes for each group and then conducts a proportion test.

Usage

proptestfordf(
  data,
  response_col,
  group_col,
  group1_label,
  group2_label,
  alternative_var = "two-sided"
)

Arguments

data

A dataframe containing the data to be tested.

response_col

The name of the column in the dataframe that contains the binary response variable.

group_col

The name of the column in the dataframe that specifies the group.

group1_label

The label for the first group to be tested.

group2_label

The label for the second group to be tested.

Value

A dataframe containing the labels for the two groups and the p-value from the proportion test.

Examples

## Not run: 
df <- data.frame(
  response = c(1, 0, 1, 0, 1, 0, 1, 0),
  group = c('A', 'A', 'B', 'B', 'A', 'A', 'B', 'B')
)
result <- proptestfordf(df, 'response', 'group', 'A', 'B')
print(result)

## End(Not run)

2024-03-23 added alternative_var

chris-hsiung/bears01 documentation built on April 9, 2024, 2:01 a.m.