如何在 R 中绘制带有预先计算统计数据的 ggplot2 箱线图?
How to draw a ggplot2 boxplot with precalculated stats in R?
我正在尝试获取预先计算的数据集的箱线图。数据集已经包含响应时间测试 I 运行 的最小值、最大值、中值、第 10 个百分位和第 90 个百分位。无论如何,是否可以从中生成 ggplot2 箱线图?
我已经包含了一个日期集示例。
谢谢,
throughput <- c(1, 2, 3, 4, 5)
response_time_min <- c(9, 19, 29, 39, 49)
response_time_10 <- c(50, 55, 60, 60, 61)
response_time_med <- c(100, 100, 100, 100, 100)
response_time_90 <- c(201, 201, 250, 200, 230)
response_time_max <- c(401, 414, 309, 402, 311)
df <- data.frame(throughput, response_time_min, response_time_10, response_time_med, response_time_90, response_time_max)
df
throughput response_time_min response_time_10 response_time_med response_time_90 response_time_max
1 1 9 50 100 201 401
2 2 19 55 100 201 414
3 3 29 60 100 250 309
4 4 39 60 100 200 402
5 5 49 61 100 230 311
是的。在 official documentation.
中搜索 "precomputed stat"
library(ggplot2)
ggplot(df) +
geom_boxplot(aes(x=factor(throughput),
ymax = response_time_max,
upper = response_time_90,
y = response_time_med,
middle = response_time_med,
lower = response_time_10,
ymin = response_time_min), stat = "identity")
我正在尝试获取预先计算的数据集的箱线图。数据集已经包含响应时间测试 I 运行 的最小值、最大值、中值、第 10 个百分位和第 90 个百分位。无论如何,是否可以从中生成 ggplot2 箱线图?
我已经包含了一个日期集示例。
谢谢,
throughput <- c(1, 2, 3, 4, 5)
response_time_min <- c(9, 19, 29, 39, 49)
response_time_10 <- c(50, 55, 60, 60, 61)
response_time_med <- c(100, 100, 100, 100, 100)
response_time_90 <- c(201, 201, 250, 200, 230)
response_time_max <- c(401, 414, 309, 402, 311)
df <- data.frame(throughput, response_time_min, response_time_10, response_time_med, response_time_90, response_time_max)
df
throughput response_time_min response_time_10 response_time_med response_time_90 response_time_max
1 1 9 50 100 201 401
2 2 19 55 100 201 414
3 3 29 60 100 250 309
4 4 39 60 100 200 402
5 5 49 61 100 230 311
是的。在 official documentation.
中搜索 "precomputed stat"library(ggplot2)
ggplot(df) +
geom_boxplot(aes(x=factor(throughput),
ymax = response_time_max,
upper = response_time_90,
y = response_time_med,
middle = response_time_med,
lower = response_time_10,
ymin = response_time_min), stat = "identity")