У меня есть фрейм данных типа a
(но с гораздо большим количеством линий), и я хотел бы создать гистограмму или гистограмму.
a <- structure(list(X.step. = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 7L, 7L, 7L,
7L, 7L, 7L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L,
8L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L), i.proba.transmission = c(0.1,
0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1, 0.1, 0.2, 0.3, 0.4,
0.5, 0.6, 0.7, 0.8, 0.9, 1, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7,
0.8, 0.9, 1, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1,
0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1, 0.1, 0.2, 0.3,
0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6,
0.7, 0.8, 0.9, 1, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9,
1, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1, 0.1, 0.2,
0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1), med.contamination = c(0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1), med.s = c(499,
499, 499, 499, 499, 499, 499, 499, 499, 499, 499, 499, 499, 499,
499, 499, 499, 499, 499, 499, 499, 499, 499, 499, 499, 499, 499,
498.5, 498, 498, 499, 499, 499, 499, 498, 498.5, 498, 498, 497.5,
498, 499, 499, 499, 498, 498, 498, 498, 498, 497, 497, 499, 499,
498, 498, 498, 498, 498, 497, 497, 497, 499, 499, 498, 498, 498,
497.5, 497, 497, 496, 496, 499, 499, 498, 498, 497, 497, 497,
496, 495.5, 495.5, 499, 499, 498, 497, 497, 497, 496.5, 495,
495.5, 494, 499, 498, 497, 497, 496, 496, 496, 495, 495, 494),
med.Ir = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.5, 2, 2, 1, 1, 1, 1, 2,
1.5, 2, 2, 2.5, 2, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 1, 1, 2,
2, 2, 2, 2, 3, 3, 3, 1, 1, 2, 2, 2, 2.5, 3, 3, 4, 4, 1, 1,
2, 2, 3, 3, 3, 4, 4.5, 4.5, 1, 1, 2, 3, 3, 3, 3.5, 5, 4.5,
6, 1, 2, 3, 3, 4, 4, 4, 5, 5, 6), med.Inr = c(0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0)), class = c("grouped_df", "tbl_df", "tbl", "data.frame"
), row.names = c(NA, -100L), groups = structure(list(X.step. = 0:9,
.rows = list(1:10, 11:20, 21:30, 31:40, 41:50, 51:60, 61:70,
71:80, 81:90, 91:100)), row.names = c(NA, -10L), class = c("tbl_df",
"tbl", "data.frame"), .drop = TRUE))
Я пробовал
# Histograme des contamination
ggplot(data = small.df)+
geom_col(aes(x = X.step., y = med.contamination, fill = i.proba.transmission),
binwidth = 0.2)+
xlim(0,300)+
theme_light()
и есть один столбец для одного X.step.
... Я хотел бы объединить 5 или 10 шагов.