Skip to content

Commit

Permalink
fix regression and remaining lints
Browse files Browse the repository at this point in the history
  • Loading branch information
IndrajeetPatil committed Nov 21, 2023
1 parent 0104a06 commit 71cc114
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 22 deletions.
12 changes: 5 additions & 7 deletions R/helpers_easystats.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,9 @@ tidy_model_parameters <- function(model, ...) {
#' tidy_model_effectsize(df)
#' @noRd
tidy_model_effectsize <- function(data, ...) {
bind_cols(
data %>%
mutate(effectsize = stats::na.omit(effectsize::get_effectsize_label(colnames(.)))) %>%
standardize_names(style = "broom") %>%
select(-contains("term")),
rename_with(as_tibble(data %@% "ci_method"), ~ paste0("conf.", .x))
)
data %>%
mutate(effectsize = stats::na.omit(effectsize::get_effectsize_label(colnames(.)))) %>%
standardize_names(style = "broom") %>%
select(-contains("term")) %>%
bind_cols(rename_with(as_tibble(data %@% "ci_method"), ~ paste0("conf.", .x)))
}
2 changes: 1 addition & 1 deletion R/one_sample_test.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ one_sample_test <- function(data,
effsize.type = "g",
...) {
type <- stats_type_switch(type)
x_vec <- stats::na.omit(data %>% pull({{ x }}))
x_vec <- stats::na.omit(pull(data, {{ x }}))

# parametric ---------------------------------------

Expand Down
16 changes: 8 additions & 8 deletions R/tidy_model_expressions.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@
#' library(statsExpressions)
#'
#' # extract a tidy data frame
#' df_expr <- tidy_model_parameters(lm(wt ~ am * cyl, mtcars))
#' df <- tidy_model_parameters(lm(wt ~ am * cyl, mtcars))
#'
#' # create a column containing expression; the expression will depend on `statistic`
#' tidy_model_expressions(df_expr, statistic = "t")
#' tidy_model_expressions(df_expr, statistic = "z")
#' tidy_model_expressions(df_expr, statistic = "chi")
#' tidy_model_expressions(df, statistic = "t")
#' tidy_model_expressions(df, statistic = "z")
#' tidy_model_expressions(df, statistic = "chi")
#' @export
tidy_model_expressions <- function(data,
statistic = NULL,
Expand Down Expand Up @@ -61,8 +61,8 @@ tidy_model_expressions <- function(data,
if (statistic == "t") {
df_expr %<>% mutate(
expression = case_when(
df_expr.error %in% c("NA", "Inf") ~ glue("list({es.text}=='{estimate}', italic(t)=='{statistic}', italic(p)=='{p.value}')"),
.default = glue("list({es.text}=='{estimate}', italic(t)('{df_expr.error}')=='{statistic}', italic(p)=='{p.value}')")
df.error %in% c("NA", "Inf") ~ glue("list({es.text}=='{estimate}', italic(t)=='{statistic}', italic(p)=='{p.value}')"),
.default = glue("list({es.text}=='{estimate}', italic(t)('{df.error}')=='{statistic}', italic(p)=='{p.value}')")
)
)
}
Expand All @@ -76,7 +76,7 @@ tidy_model_expressions <- function(data,
# chi^2-statistic -----------------------------

if (statistic == "c") {
df_expr %<>% mutate(expression = glue("list({es.text}=='{estimate}', italic(chi)^2*('{df_expr.error}')=='{statistic}', italic(p)=='{p.value}')"))
df_expr %<>% mutate(expression = glue("list({es.text}=='{estimate}', italic(chi)^2*('{df.error}')=='{statistic}', italic(p)=='{p.value}')"))
}

# f-statistic ---------------------------------
Expand All @@ -85,7 +85,7 @@ tidy_model_expressions <- function(data,
if (effsize.type == "eta") es.text <- list(quote(widehat(italic(eta)[p]^2)))
if (effsize.type == "omega") es.text <- list(quote(widehat(italic(omega)[p]^2)))

df_expr %<>% mutate(expression = glue("list({es.text}=='{estimate}', italic(F)('{df_expr}', '{df_expr.error}')=='{statistic}', italic(p)=='{p.value}')"))
df_expr %<>% mutate(expression = glue("list({es.text}=='{estimate}', italic(F)('{df}', '{df.error}')=='{statistic}', italic(p)=='{p.value}')"))
}

# nolint end
Expand Down
8 changes: 4 additions & 4 deletions man/tidy_model_expressions.Rd

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

4 changes: 2 additions & 2 deletions tests/testthat/test-contingency_table.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ test_that(
expect_snapshot(select(df1, -expression))
expect_snapshot(df1[["expression"]])


set.seed(123)
df2 <- contingency_table(
data = as.data.frame(Titanic),
Expand Down Expand Up @@ -121,7 +121,7 @@ test_that(
expect_snapshot(select(df1, -expression))
expect_snapshot(df1[["expression"]])


set.seed(123)
df2 <- contingency_table(
data = as.data.frame(Titanic),
Expand Down

0 comments on commit 71cc114

Please sign in to comment.