prop_ci | R Documentation |
For a data frame input, one variable is a binary target (target_name
) and another is selected to
be a predictor variable (var_name
). Mean response and a confidence interval is calculated for the
target variable for each level or value of the predictor. The results are plotted and returned as a
table. The function most appropriate for factor predictors but will work with other variable types also.
prop_ci(
dt,
target_name,
var_name,
min_n = 1,
show_all = TRUE,
order_n = NULL,
conf_level = 0.95,
prop_lim = NULL,
pos_class = NULL,
plot = TRUE,
return_plot = FALSE
)
dt |
A data frame. |
target_name |
Column to use as target variable. Column name (quoted or unquoted) or position. |
var_name |
Column to use as predictor variable. Column name (quoted or unquoted) or position. |
min_n |
Integer >= 1. Predictor levels with less than |
show_all |
Logical. Defaults to |
order_n |
Logical. Whether to force plot and table to order by number of observations of the
predictior. The default setting |
conf_level |
Numeric in (0,1). Confidence level used for confidence intervals. |
prop_lim |
Optional x axis limits passed to |
pos_class |
Optional. Specify value in target to associate with class 1. |
plot |
Optional logical. Output a plot or not. |
return_plot |
Optional logical. If |
The target variable must be binary. Top compute confidence intervals this is converted to 0 and 1 values.
If it is not obvious which value corresponds to 1 and which to 0 then it will be based on level order
if a factor and the first observation otherwise. Giving the value of corresponding to 1 in the argument
pos_class
will override this.
Use the plot
and return_plot
arguments to control output. By default (designed to be
used interactively) returns a table and prints a plot. If return_plot = TRUE
then just the
plot is returned. If return_plot = FALSE
and
plot = FALSE
then the table is returned and no plot is generated. The default
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.