# Basic usage with single variable (no grouping)
y <- rnorm(100)
plot_cdf(y)
# Basic usage with formula syntax and grouping
group <- rep(c("A", "B", "C"), c(30, 40, 30))
plot_cdf(y ~ group)
# With custom colors (scalar - same for all)
plot_cdf(y ~ group, col = "blue")
# With custom colors (vector - different for each group)
plot_cdf(y ~ group, col = c("red", "green", "blue"))
# Multiple parameters
plot_cdf(y ~ group, col = c("red", "green", "blue"), lwd = c(1, 2, 3))
# With line type and point character
plot_cdf(y ~ group, col = c("red", "green", "blue"), lty = c(1, 2, 3), lwd = 2)
# Using data frame
df <- data.frame(value = rnorm(100), group = rep(c("A", "B"), 50))
plot_cdf(value ~ group, data = df)
plot_cdf(value ~ group, data = df, col = c("red", "blue"))
# Compare two vectors
y1 <- rnorm(50)
y2 <- rnorm(50, mean = 1)
plot_cdf(y1, y2)
# Formula syntax without data (variables evaluated from environment)
widgetness <- rnorm(100)
gender <- rep(c("M", "F"), 50)
plot_cdf(widgetness ~ gender)
# Using the returned object
df <- data.frame(value = c(rnorm(50, 0), rnorm(50, 1)), group = rep(c("A", "B"), each = 50))
result <- plot_cdf(value ~ group, data = df)
# Use ECDF to find P(X <= 0.5) for group A
result$ecdfs[[1]](0.5)
# Access KS test p-value
result$ks_test$p.value
# Summarize median quantile regression
summary(result$quantile_regression_50)
Run the code above in your browser using DataLab