From 9894d86839f4e303f40bf6f74cfc4416238cdb99 Mon Sep 17 00:00:00 2001 From: JTPetter <61797391+JTPetter@users.noreply.github.com> Date: Fri, 6 Dec 2024 15:12:57 +0100 Subject: [PATCH] Learn Stats: Fix 0.19.2 bugs (#91) --- DESCRIPTION | 4 +++- R/LSTdescriptives.R | 15 +++++++++++---- R/LSeffectSizes.R | 6 +++--- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 447a684..6f2b8ee 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -18,7 +18,9 @@ Imports: jaspTTests, ggforce, tidyr, - igraph + igraph, + HDInterval, + metafor Remotes: jasp-stats/jaspBase, jasp-stats/jaspGraphs, diff --git a/R/LSTdescriptives.R b/R/LSTdescriptives.R index 11b8335..b994ddc 100644 --- a/R/LSTdescriptives.R +++ b/R/LSTdescriptives.R @@ -24,12 +24,18 @@ LSTdescriptives <- function(jaspResults, dataset, options, state = NULL) { data <- .getDataLSTdesc(jaspResults, options, inputType) #checking whether data is discrete or continuous, whereas only integers are treated as discrete - discrete <- ifelse(all(data$x == as.integer(data$x)), TRUE, FALSE) + integerData <- as.integer(data$x) + # conversion to integers fails with extreme values, if it failed for any value just treat it as continuous + if (any(is.na(integerData))) { + discrete <- FALSE + } else { + discrete <- ifelse(all(data$x == integerData), TRUE, FALSE) + } stats <- switch(options[["LSdescStatistics"]], - "LSdescMean" = "ct", "LSdescMedian" = "ct", "LSdescMode" = "ct", "LSdescMMM" = "ct", - "LSdescRange" = "spread", "LSdescQR" = "spread", "LSdescSD" = "spread", - "none" = "none") + "LSdescMean" = "ct", "LSdescMedian" = "ct", "LSdescMode" = "ct", "LSdescMMM" = "ct", + "LSdescRange" = "spread", "LSdescQR" = "spread", "LSdescSD" = "spread", + "none" = "none") if (options[["LSdescHistBar"]]) @@ -497,6 +503,7 @@ LSTdescriptives <- function(jaspResults, dataset, options, state = NULL) { variable <- variable[variable != ""] dataset <- .readDataSetToEnd(columns.as.numeric = variable) df <- data.frame(x = unlist(dataset)) + df <- na.omit(df) return(df) } diff --git a/R/LSeffectSizes.R b/R/LSeffectSizes.R index b6bbe25..66b11bb 100644 --- a/R/LSeffectSizes.R +++ b/R/LSeffectSizes.R @@ -517,7 +517,7 @@ switchOptions <- function(options) { rhoTable <- createJaspContainer() rhoTable$position <- 3 rhoTable$dependOn(c("effectSize", "effectSizeValueRho", "simulateData", "simulateDataN", - "rhoSharedVariance", "setSeed", "seed")) + "rhoSharedVariance", "setSeed", "seed", "explanatoryTexts")) jaspResults[["rhoTable"]] <- rhoTable @@ -712,7 +712,7 @@ switchOptions <- function(options) { if (options[["plotRhoRegression"]]) { plot <- plot + ggplot2::geom_abline( - intercept = mu2, + intercept = mu2 - (rho * (sigma2/sigma1)) * mu1, slope = rho * (sigma2/sigma1) ) } @@ -936,7 +936,7 @@ switchOptions <- function(options) { phiTable <- createJaspContainer() phiTable$position <- 3 - phiTable$dependOn(c("effectSize", "effectSizeValuePhi", "simulateData", "simulateDataN", "pX", "pY", "inputPopulation", "pX1Y1", "pX1Y0", "pX0Y1", "pX0Y0", "setSeed", "seed", "phiOR", "phiRR", "phiRD")) + phiTable$dependOn(c("effectSize", "effectSizeValuePhi", "simulateData", "simulateDataN", "pX", "pY", "inputPopulation", "pX1Y1", "pX1Y0", "pX0Y1", "pX0Y0", "setSeed", "seed", "phiOR", "phiRR", "phiRD", "explanatoryTexts")) jaspResults[["phiTable"]] <- phiTable