View source: R/proptestfordf.R
proptestfordf | R Documentation |
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.
proptestfordf(
data,
response_col,
group_col,
group1_label,
group2_label,
alternative_var = "two-sided"
)
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. |
A dataframe containing the labels for the two groups and the p-value from the proportion test.
## 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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.