set.seed(1)
meta_data <- data.frame(
Type = factor(
sample(c("A", "B", "C"),
50,
replace = TRUE,
prob = c(0.5, 0.3, 0.2)
)
),
Group = factor(sample(c("X", "Y", "Z"), 50, replace = TRUE)),
Batch = factor(sample(c("B1", "B2"), 50, replace = TRUE))
)
meta_data$Region <- factor(
ifelse(meta_data$Group %in% c("X", "Y"), "R1", "R2"),
levels = c("R1", "R2")
)
StatPlot(
meta_data,
stat.by = "Type",
group.by = "Group",
split.by = "Batch",
plot_type = "bar",
position = "dodge"
)
StatPlot(
meta_data,
stat.by = "Type",
group.by = "Group",
stat_type = "count",
plot_type = "ring",
position = "dodge"
)
StatPlot(
meta_data,
stat.by = "Type",
group.by = "Group",
stat_type = "count"
)
StatPlot(
meta_data,
stat.by = "Type",
plot_type = "pie"
)
StatPlot(
meta_data,
stat.by = "Type",
group.by = "Group",
stat_type = "count",
plot_type = "area"
)
StatPlot(
meta_data,
stat.by = "Type",
group.by = "Group",
plot_type = "dot"
)
StatPlot(
meta_data,
stat.by = "Type",
group.by = "Group",
stat_type = "count",
plot_type = "trend"
)
Run the code above in your browser using DataLab