Jump to content

File:Groupjitterboxplot.png

From 太極
Revision as of 13:33, 17 April 2025 by Brb (talk | contribs) (<syntaxhighlight lang='r'> library(ggplot2) library(dplyr) # Create a sample dataset with large sample size set.seed(42) n_per_group <- 500 # 500 samples per group and category combination (2000 total) data <- data.frame( A = rep(c("Group1", "Group2"), each = n_per_group * 2), B = c(rnorm(n_per_group, 10, 2), rnorm(n_per_group, 8, 1.5), # Group1: Category1, Category2 rnorm(n_per_group, 12, 2.5), rnorm(n_per_group, 14, 2)), # Group2: Category1, Category2 F = rep(rep(c("Categ...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Original file (1,000 × 1,000 pixels, file size: 247 KB, MIME type: image/png)

Summary

library(ggplot2)
library(dplyr)

# Create a sample dataset with large sample size
set.seed(42)
n_per_group <- 500  # 500 samples per group and category combination (2000 total)

data <- data.frame(
  A = rep(c("Group1", "Group2"), each = n_per_group * 2),
  B = c(rnorm(n_per_group, 10, 2), rnorm(n_per_group, 8, 1.5),   # Group1: Category1, Category2
        rnorm(n_per_group, 12, 2.5), rnorm(n_per_group, 14, 2)), # Group2: Category1, Category2
  F = rep(rep(c("Category1", "Category2"), each = n_per_group), 2)
)

# View data dimensions
dim(data)
# Check the first few rows
head(data)

# Visualize with jittered points under boxplots
data %>% 
  ggplot(aes(x = A, y = B, fill = F)) + 
  geom_jitter(aes(color = F), 
              position = position_jitterdodge(jitter.width = 0.2, 
                                             dodge.width = 0.75,
                                             seed = 123),
              alpha = 0.3) + 
  geom_boxplot(outlier.shape = NA, alpha = 0.7)

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current13:33, 17 April 2025Thumbnail for version as of 13:33, 17 April 20251,000 × 1,000 (247 KB)Brb (talk | contribs)<syntaxhighlight lang='r'> library(ggplot2) library(dplyr) # Create a sample dataset with large sample size set.seed(42) n_per_group <- 500 # 500 samples per group and category combination (2000 total) data <- data.frame( A = rep(c("Group1", "Group2"), each = n_per_group * 2), B = c(rnorm(n_per_group, 10, 2), rnorm(n_per_group, 8, 1.5), # Group1: Category1, Category2 rnorm(n_per_group, 12, 2.5), rnorm(n_per_group, 14, 2)), # Group2: Category1, Category2 F = rep(rep(c("Categ...

The following page uses this file: