Skip to content

Commit

Permalink
added the p adjustment methods for LSD and kruskal wallis posthoc tes…
Browse files Browse the repository at this point in the history
…t as UIoutput
  • Loading branch information
Konrad1991 committed Nov 18, 2024
1 parent ae7da73 commit fc35c5b
Showing 1 changed file with 33 additions and 17 deletions.
50 changes: 33 additions & 17 deletions bs/R/statisticalTests.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,7 @@ testsSidebarUI <- function(id) {
"Unbalanced" = "ub"
)
),
conditionalPanel(
condition = "input.PostHocTests == 'kruskalPHTest' || input.PostHocTests == 'lsdTest'",
selectInput(NS(id, "padj"), "Adjusted p method",
c(
"Holm" = "holm",
"Hommel" = "hommel",
"Hochberg" = "hochberg",
"Bonferroni" = "bonferroni",
"BH" = "BH",
"BY" = "BY",
"fdr" = "fdr"
),
selectize = FALSE
)
)
uiOutput(NS(id, "padj"))
)
)
}
Expand Down Expand Up @@ -122,6 +108,28 @@ testsUI <- function(id) {

testsServer <- function(id, data, listResults) {
moduleServer(id, function(input, output, session) {
# Render p adjustment methods
output[["padj"]] <- renderUI({
if (input$PostHocTests == "kruskalTest" || input$PostHocTests == "LSD") {
return(
selectInput(NS(id, "padj"), "Adjusted p method",
c(
"Holm" = "holm",
"Hommel" = "hommel",
"Hochberg" = "hochberg",
"Bonferroni" = "bonferroni",
"BH" = "BH",
"BY" = "BY",
"fdr" = "fdr"
),
selectize = FALSE
)
)
}
# condition = "input.PostHocTests == 'kruskalTest' || input.PostHocTests == 'Least significant difference test'",

})

# Render split by group
output[["open_split_by_group"]] <- renderUI({
actionButton(NS(id, "open_split_by_group"),
Expand Down Expand Up @@ -187,7 +195,9 @@ testsServer <- function(id, data, listResults) {
FormulaEditorUI("FO"),
easyClose = TRUE,
size = "l",
footer = NULL
footer = tagList(
modalButton("Close")
)
))
})

Expand All @@ -214,14 +224,17 @@ testsServer <- function(id, data, listResults) {
}
fit <- broom::tidy(t.test(formula,
data = df, conf.level = input$confLevel,
alternative = input$alt, var.equal = eq
alternative = input$altHyp, var.equal = eq
))
})
if (inherits(e, "try-error")) {
err <- conditionMessage(attr(e, "condition"))
output$test_error <- renderText(err)
} else {
listResults$curr_data <- fit
exportTestValues(
tests_res = fit
)
listResults$curr_name <- paste("Test Nr", length(listResults$all_names) + 1, "Conducted t-test")
output$test_result <- renderTable(fit, digits = 6)
}
Expand Down Expand Up @@ -310,6 +323,9 @@ testsServer <- function(id, data, listResults) {
} else {
fit <- cbind(fit, row.names(fit))
names(fit)[ncol(fit)] <- paste0(indep, collapse = ".")
exportTestValues(
tests_res = fit
)
listResults$curr_data <- fit
listResults$curr_name <- paste("Test Nr", length(listResults$all_names) + 1, "Conducted: ", method)
output$test_result <- renderTable(fit, digits = 6)
Expand Down

0 comments on commit fc35c5b

Please sign in to comment.