In-class_Exercise 4

Author

Zou Jiaxun

Published

May 4, 2024

pacman::p_load(tidyverse, ggstatsplot)
exam <- read_csv("data/Exam_data.csv")
set.seed(1234)

gghistostats(
  data = exam,
  x = ENGLISH,
  type = "np",
  #type = "parametric",
  test.value = 60,
  bin.args = list(color = "black",
                  fill = "grey50",
                  alpha = 0.7),
  normal.curve = FALSE,
  normal.curve.args = list(linewidth = 2),
  xlab = "English scores"
)

set.seed(1234)

p <- gghistostats(
  data = exam,
  x = ENGLISH,
  type = "np",
  #type = "parametric",
  #type = "robust",
  #type = "bayes",
  test.value = 60,
  bin.args = list(color = "black",
                  fill = "grey50",
                  alpha = 0.7),
  normal.curve = FALSE,
  #normal.curve = TRUE, #(show the normal distribution)
  normal.curve.args = list(linewidth = 2),
  xlab = "English scores"
)
extract_stats(p)
$subtitle_data
# A tibble: 1 × 12
  statistic  p.value method                    alternative effectsize       
      <dbl>    <dbl> <chr>                     <chr>       <chr>            
1     38743 3.43e-16 Wilcoxon signed rank test two.sided   r (rank biserial)
  estimate conf.level conf.low conf.high conf.method n.obs expression
     <dbl>      <dbl>    <dbl>     <dbl> <chr>       <int> <list>    
1    0.528       0.95    0.430     0.613 normal        322 <language>

$caption_data
NULL

$pairwise_comparisons_data
NULL

$descriptive_data
NULL

$one_sample_data
NULL

$tidy_data
NULL

$glance_data
NULL
ggdotplotstats(
  data = exam,
  x = ENGLISH,
  y = CLASS,
  title = "",
  xlab = ""
)

exam_long <- exam %>%
  pivot_longer(
    cols = ENGLISH:SCIENCE,
    names_to = "SUBJECT",
    values_to = "SCORES") %>%
 filter(CLASS == "3A")
ggwithinstats(data = filter(exam_long,
                            SUBJECT %in% c("ENGLISH", "SCIENCE")),
              x = "SUBJECT",
              y = "SCORES",
              type = "p")