@@ -57,7 +57,7 @@ t_test <- function(x, formula,
5757 conf_int = TRUE ,
5858 conf_level = 0.95 ,
5959 ... ) {
60-
60+
6161 check_conf_level(conf_level )
6262
6363 # convert all character and logical variables to be factor variables
@@ -170,7 +170,7 @@ t_stat <- function(x, formula,
170170 msg = c(" The t_stat() wrapper has been deprecated in favor of the more " ,
171171 " general observe(). Please use that function instead." )
172172 )
173-
173+
174174 check_conf_level(conf_level )
175175
176176 # convert all character and logical variables to be factor variables
@@ -256,9 +256,9 @@ chisq_test <- function(x, formula, response = NULL,
256256 # Parse response and explanatory variables
257257 response <- enquo(response )
258258 explanatory <- enquo(explanatory )
259-
259+
260260 x <- standardize_variable_types(x )
261-
261+
262262 x <- parse_variables(x = x , formula = formula ,
263263 response = response , explanatory = explanatory )
264264
@@ -290,7 +290,7 @@ chisq_test <- function(x, formula, response = NULL,
290290# '
291291# ' A shortcut wrapper function to get the observed test statistic for a chisq
292292# ' test. Uses [chisq.test()][stats::chisq.test()], which applies a continuity
293- # ' correction. This function has been deprecated in favor of the more
293+ # ' correction. This function has been deprecated in favor of the more
294294# ' general [observe()].
295295# '
296296# ' @param x A data frame that can be coerced into a [tibble][tibble::tibble].
@@ -327,15 +327,15 @@ chisq_stat <- function(x, formula, response = NULL,
327327 explanatory = NULL , ... ) {
328328 .Deprecated(
329329 new = " observe" ,
330- msg = c(" The chisq_stat() wrapper has been deprecated in favor of the " ,
330+ msg = c(" The chisq_stat() wrapper has been deprecated in favor of the " ,
331331 " more general observe(). Please use that function instead." )
332332 )
333-
333+
334334 # Parse response and explanatory variables
335335 response <- enquo(response )
336336 explanatory <- enquo(explanatory )
337337 x <- standardize_variable_types(x )
338-
338+
339339 x <- parse_variables(x = x , formula = formula ,
340340 response = response , explanatory = explanatory )
341341
@@ -364,7 +364,7 @@ chisq_stat <- function(x, formula, response = NULL,
364364
365365check_conf_level <- function (conf_level ) {
366366 if (
367- (class (conf_level ) != " numeric" ) | (conf_level < 0 ) | (conf_level > 1 )
367+ (! inherits (conf_level , " numeric" ) ) | (conf_level < 0 ) | (conf_level > 1 )
368368 ) {
369369 stop_glue(" The `conf_level` argument must be a number between 0 and 1." )
370370 }
@@ -409,8 +409,8 @@ check_conf_level <- function(conf_level) {
409409# ' a string. Only used when testing the null that a single
410410# ' proportion equals a given value, or that two proportions are equal;
411411# ' ignored otherwise.
412- # ' @param correct A logical indicating whether Yates' continuity correction
413- # ' should be applied where possible. If `z = TRUE`, the `correct` argument will
412+ # ' @param correct A logical indicating whether Yates' continuity correction
413+ # ' should be applied where possible. If `z = TRUE`, the `correct` argument will
414414# ' be overwritten as `FALSE`. Otherwise defaults to `correct = TRUE`.
415415# ' @param z A logical value for whether to report the statistic as a standard
416416# ' normal deviate or a Pearson's chi-square statistic. \eqn{z^2} is distributed
@@ -431,7 +431,7 @@ check_conf_level <- function(conf_level) {
431431# ' prop_test(gss,
432432# ' college ~ NULL,
433433# ' p = .2)
434- # '
434+ # '
435435# ' # report as a z-statistic rather than chi-square
436436# ' # and specify the success level of the response
437437# ' prop_test(gss,
@@ -458,10 +458,10 @@ prop_test <- function(x, formula,
458458 response <- enquo(response )
459459 explanatory <- enquo(explanatory )
460460 x <- standardize_variable_types(x )
461-
461+
462462 x <- parse_variables(x = x , formula = formula ,
463463 response = response , explanatory = explanatory )
464-
464+
465465 correct <- if (z ) {FALSE } else if (is.null(correct )) {TRUE } else {correct }
466466
467467 if (! (class(response_variable(x )) %in% c(" logical" , " character" , " factor" ))) {
@@ -535,7 +535,7 @@ prop_test <- function(x, formula,
535535 p = p ,
536536 correct = correct ,
537537 ... )
538-
538+
539539 }
540540
541541 if (length(prelim $ estimate ) < = 2 ) {
@@ -563,7 +563,7 @@ prop_test <- function(x, formula,
563563 chisq_df = parameter ,
564564 p_value = p.value )
565565 }
566-
566+
567567 if (z ) {
568568 results <- calculate_z(x , results , success , p , order )
569569 }
@@ -573,9 +573,9 @@ prop_test <- function(x, formula,
573573
574574calculate_z <- function (x , results , success , p , order ) {
575575 exp <- if (has_explanatory(x )) {explanatory_name(x )} else {" NULL" }
576-
576+
577577 form <- as.formula(paste0(response_name(x ), " ~ " , exp ))
578-
578+
579579 stat <- x %> %
580580 specify(formula = form , success = success ) %> %
581581 hypothesize(
@@ -587,9 +587,9 @@ calculate_z <- function(x, results, success, p, order) {
587587 order = if (has_explanatory(x )) {order } else {NULL }
588588 ) %> %
589589 dplyr :: pull()
590-
590+
591591 results $ statistic <- stat
592592 results $ chisq_df <- NULL
593-
593+
594594 results
595595}
0 commit comments