Skip to content

Commit

Permalink
merge pr #453: v1.0.2 release candidate
Browse files Browse the repository at this point in the history
  • Loading branch information
simonpcouch authored Jun 12, 2022
2 parents 736e934 + bbd8c2b commit 06e2977
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 29 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Type: Package
Package: infer
Title: Tidy Statistical Inference
Version: 1.0.1.9000
Version: 1.0.2
Authors@R:
c(person(given = "Andrew",
family = "Bray",
role = c("aut", "cre"),
role = "aut",
email = "abray@reed.edu"),
person(given = "Chester",
family = "Ismay",
Expand All @@ -19,7 +19,7 @@ Authors@R:
comment = c(ORCID = "0000-0002-1617-4019")),
person(given = "Simon",
family = "Couch",
role = "aut",
role = c("aut", "cre"),
email = "simonpatrickcouch@gmail.com",
comment = c(ORCID = "0000-0001-5676-5107")),
person(given = "Ben",
Expand Down
5 changes: 1 addition & 4 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# infer v1.0.1.9000 (Development Version)

To be released as v1.0.2.

# infer v1.0.2

* Fix p-value shading when the calculated statistic falls exactly on the boundaries of a histogram bin (#424).
* Fix `generate()` errors when columns are named `x` (#431).
Expand Down
40 changes: 20 additions & 20 deletions R/wrappers.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ t_test <- function(x, formula,
conf_int = TRUE,
conf_level = 0.95,
...) {

check_conf_level(conf_level)

# convert all character and logical variables to be factor variables
Expand Down Expand Up @@ -170,7 +170,7 @@ t_stat <- function(x, formula,
msg = c("The t_stat() wrapper has been deprecated in favor of the more " ,
"general observe(). Please use that function instead.")
)

check_conf_level(conf_level)

# convert all character and logical variables to be factor variables
Expand Down Expand Up @@ -256,9 +256,9 @@ chisq_test <- function(x, formula, response = NULL,
# Parse response and explanatory variables
response <- enquo(response)
explanatory <- enquo(explanatory)

x <- standardize_variable_types(x)

x <- parse_variables(x = x, formula = formula,
response = response, explanatory = explanatory)

Expand Down Expand Up @@ -290,7 +290,7 @@ chisq_test <- function(x, formula, response = NULL,
#'
#' A shortcut wrapper function to get the observed test statistic for a chisq
#' test. Uses [chisq.test()][stats::chisq.test()], which applies a continuity
#' correction. This function has been deprecated in favor of the more
#' correction. This function has been deprecated in favor of the more
#' general [observe()].
#'
#' @param x A data frame that can be coerced into a [tibble][tibble::tibble].
Expand Down Expand Up @@ -327,15 +327,15 @@ chisq_stat <- function(x, formula, response = NULL,
explanatory = NULL, ...) {
.Deprecated(
new = "observe",
msg = c("The chisq_stat() wrapper has been deprecated in favor of the ",
msg = c("The chisq_stat() wrapper has been deprecated in favor of the ",
"more general observe(). Please use that function instead.")
)

# Parse response and explanatory variables
response <- enquo(response)
explanatory <- enquo(explanatory)
x <- standardize_variable_types(x)

x <- parse_variables(x = x, formula = formula,
response = response, explanatory = explanatory)

Expand Down Expand Up @@ -364,7 +364,7 @@ chisq_stat <- function(x, formula, response = NULL,

check_conf_level <- function(conf_level) {
if (
(class(conf_level) != "numeric") | (conf_level < 0) | (conf_level > 1)
(!inherits(conf_level, "numeric")) | (conf_level < 0) | (conf_level > 1)
) {
stop_glue("The `conf_level` argument must be a number between 0 and 1.")
}
Expand Down Expand Up @@ -409,8 +409,8 @@ check_conf_level <- function(conf_level) {
#' a string. Only used when testing the null that a single
#' proportion equals a given value, or that two proportions are equal;
#' ignored otherwise.
#' @param correct A logical indicating whether Yates' continuity correction
#' should be applied where possible. If `z = TRUE`, the `correct` argument will
#' @param correct A logical indicating whether Yates' continuity correction
#' should be applied where possible. If `z = TRUE`, the `correct` argument will
#' be overwritten as `FALSE`. Otherwise defaults to `correct = TRUE`.
#' @param z A logical value for whether to report the statistic as a standard
#' normal deviate or a Pearson's chi-square statistic. \eqn{z^2} is distributed
Expand All @@ -431,7 +431,7 @@ check_conf_level <- function(conf_level) {
#' prop_test(gss,
#' college ~ NULL,
#' p = .2)
#'
#'
#' # report as a z-statistic rather than chi-square
#' # and specify the success level of the response
#' prop_test(gss,
Expand All @@ -458,10 +458,10 @@ prop_test <- function(x, formula,
response <- enquo(response)
explanatory <- enquo(explanatory)
x <- standardize_variable_types(x)

x <- parse_variables(x = x, formula = formula,
response = response, explanatory = explanatory)

correct <- if (z) {FALSE} else if (is.null(correct)) {TRUE} else {correct}

if (!(class(response_variable(x)) %in% c("logical", "character", "factor"))) {
Expand Down Expand Up @@ -535,7 +535,7 @@ prop_test <- function(x, formula,
p = p,
correct = correct,
...)

}

if (length(prelim$estimate) <= 2) {
Expand Down Expand Up @@ -563,7 +563,7 @@ prop_test <- function(x, formula,
chisq_df = parameter,
p_value = p.value)
}

if (z) {
results <- calculate_z(x, results, success, p, order)
}
Expand All @@ -573,9 +573,9 @@ prop_test <- function(x, formula,

calculate_z <- function(x, results, success, p, order) {
exp <- if (has_explanatory(x)) {explanatory_name(x)} else {"NULL"}

form <- as.formula(paste0(response_name(x), " ~ ", exp))

stat <- x %>%
specify(formula = form, success = success) %>%
hypothesize(
Expand All @@ -587,9 +587,9 @@ calculate_z <- function(x, results, success, p, order) {
order = if (has_explanatory(x)) {order} else {NULL}
) %>%
dplyr::pull()

results$statistic <- stat
results$chisq_df <- NULL

results
}
5 changes: 3 additions & 2 deletions man/infer.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 06e2977

Please sign in to comment.