Skip to content

Commit

Permalink
Adding total as parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
lilyclements authored Sep 24, 2024
1 parent 6cfface commit 962c0b2
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions instat/static/InstatObject/R/data_object_R6.R
Original file line number Diff line number Diff line change
Expand Up @@ -4524,7 +4524,7 @@ DataSheet$set("public", "has_labels", function(col_names) {
}
)

DataSheet$set("public", "anova_tables2", function(x_col_names, y_col_name, signif.stars = FALSE, sign_level = FALSE, means = FALSE) {
DataSheet$set("public", "anova_tables2", function(x_col_names, y_col_name, total = TRUE, signif.stars = FALSE, sign_level = FALSE, means = FALSE) {
if(missing(x_col_names) || missing(y_col_name)) stop("Both x_col_names and y_col_names are required")
if(sign_level || signif.stars) message("This is no longer descriptive")
if(sign_level) end_col = 5 else end_col = 4
Expand All @@ -4536,11 +4536,9 @@ DataSheet$set("public", "anova_tables2", function(x_col_names, y_col_name, signi
}

return_item <- NULL
mod <- lm(formula = as.formula(formula_str), data = self$get_data_frame())
anova_mod <- anova(mod)[1:end_col] %>%
tibble::as_tibble(rownames = " ") %>%
tibble::add_row(` ` = "Total",
dplyr::summarise(., across(where(is.numeric), sum)))
mod <- lm(formula = as.formula(formula_str), data = self$get_data_frame())
anova_mod <- anova(mod)[1:end_col] %>% tibble::as_tibble(rownames = " ")
if (total) anova_mod <- anova_mod %>% tibble::add_row(` ` = "Total", dplyr::summarise(., across(where(is.numeric), sum)))
return_item[[paste0("ANOVA table: ", formula_str, sep = "")]] <- anova_mod
if(means){
if (class(mod$model[[x_col_names]]) == "numeric"){
Expand Down

0 comments on commit 962c0b2

Please sign in to comment.