IndrajeetPatil / ggstatsplot

Enhancing {ggplot2} plots with statistical analysis 📊📣
https://indrajeetpatil.github.io/ggstatsplot/
GNU General Public License v3.0
1.99k stars 184 forks source link

Statistical report not appearing #960

Open manoelsiq opened 5 hours ago

manoelsiq commented 5 hours ago

Even though the function to report the statistical test results is activated (results.subtitle = TRUE), the results do not appear in all graphs. In some, they do not appear for no apparent reason. Below is the code I am using:

ggstatsplot::ggbarstats( data = det2019, x = VD, y = deslocamento, xlab = "Deslocamentos", ylab = "Percentual", digits.perc = 1, label.text.size = 4, package = "wesanderson", palette = "Royal1", messages = FALSE, bf.message = FALSE, results.subtitle = TRUE, proportion.test = FALSE) + theme(legend.position = "bottom")

IndrajeetPatil commented 5 hours ago

Can you please provide a reproducible example? I don't know what det2019 is.

manoelsiq commented 4 hours ago

Sure. This is a version of my dataset:

ausencia_desl1 <- rep("Deslocamento 1", 456)
ausencia_desl2 <- rep("Deslocamento 2", 321)
ausencia_desl3 <- rep("Deslocamento 3", 339)
ausencia_desl4 <- rep("Deslocamento 4", 334)
presenca_desl1 <- rep("Deslocamento 1", 392)
presenca_desl2 <- rep("Deslocamento 2", 295)
presenca_desl3 <- rep("Deslocamento 3", 299)
presenca_desl4 <- rep("Deslocamento 4", 359)

deslocamentos <- c(ausencia_desl1, ausencia_desl2, ausencia_desl3, ausencia_desl4, presenca_desl1, presenca_desl2, presenca_desl3, presenca_desl4)

VD <- factor(c(rep("ausência", 1450), rep("presença", 1345)))

set.seed(123)  
deslocamentos <- sample(deslocamentos)
VD <- sample(VD)

det2019 <- data.frame(VD, deslocamentos)

However, the statistical tests are not reported when using the code (with my dataset).

ggstatsplot::ggbarstats(
  data = det2019,
  x = VD,
  y = deslocamentos,
  xlab = "Deslocamentos",
  ylab = "Percentual",
  digits.perc = 1,
  label.text.size = 4,
  package = "wesanderson",
  palette = "Royal1",
  messages = FALSE,
  bf.message = FALSE,
  results.subtitle = TRUE,
  proportion.test = FALSE) + 
  theme(legend.position = "bottom")

The figure looks like the one attached, with no statistical report (I know it's not significant, but the reporting in the figure is important): Rplot