add_prop_test | R Documentation |
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
)
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 )
.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 |
Data frame with columns added
count_by()
library(magrittr) if (requireNamespace("survival", quietly = TRUE)) { survival::aml %>% count_by(x) %>% add_prop_test(n, sum(n), rel) }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.