if (FALSE) {
# Generate example data:
# x is the variable of interest
# y is the grouping variable
example_data <- data.frame(x = rnorm(40), y = rep(c(1,2), 20))
# Two-sample test:
boot_median_test(x ~ y, data = example_data, R = 999)
# Two-sample test using the pipe:
example_data |> boot_median_test(x ~ y, R = 999)
# With a directed alternative hypothesis:
example_data |> boot_median_test(x ~ y, R = 999, alternative = "greater")
# One-sample test:
boot_median_test(example_data$x, R = 999)
# One-sample test using the pipe:
example_data |> boot_median_test(x ~ 1, R = 999)
# With a directed alternative hypothesis:
example_data |> boot_median_test(x ~ 1, R = 999, mu = 0.5, alternative = "less")
# Paired test:
boot_median_test(example_data$x[example_data$y==1],
example_data$x[example_data$y==2],
paired = TRUE, R = 999)
# Paired test using the pipe (after reshaping to wide format):
example_data$id <- rep(1:20, rep(2, 20))
example_data2 <- reshape(example_data, direction = "wide",
idvar = "id", timevar = "y")
example_data2 |> boot_median_test(Pair(x.1, x.2) ~ 1)
}
Run the code above in your browser using DataLab