Saya memiliki data kecelakaan kendaraan bermotor menurut jam sehari. Seperti yang Anda harapkan, mereka tinggi di tengah hari dan puncaknya pada jam sibuk. Geom_density default ggplot2 memuluskannya dengan baik
Subset dari data, untuk crash terkait drive-minum, tinggi di kedua ujung hari (malam hari dan pagi hari) dan tertinggi di ekstrem. Tapi geom_density default ggplot2 masih menurun di sisi kanan ekstrim.
Apa yang harus dilakukan? Tujuannya hanyalah visualisasi - tidak perlu (ada?) Untuk analisis statistik yang kuat.
x <- structure(list(hour = c(14, 1, 1, 9, 2, 11, 20, 5, 22, 13, 21,
2, 22, 10, 18, 0, 2, 1, 2, 15, 20, 23, 17, 3, 3, 16, 19, 23,
3, 4, 4, 22, 2, 21, 20, 1, 19, 18, 17, 23, 23, 3, 11, 4, 23,
4, 7, 2, 3, 19, 2, 18, 3, 17, 1, 9, 19, 23, 9, 6, 2, 1, 23, 21,
22, 22, 22, 20, 1, 21, 6, 2, 22, 23, 19, 17, 19, 3, 22, 21, 4,
10, 17, 23, 3, 7, 19, 16, 2, 23, 4, 5, 1, 20, 7, 21, 19, 2, 21)
, count = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L))
, .Names = c("hour", "count")
, row.names = c(8L, 9L, 10L, 29L, 33L, 48L, 51L, 55L, 69L, 72L, 97L, 108L, 113L,
118L, 126L, 140L, 150L, 171L, 177L, 184L, 202L, 230L, 236L, 240L,
242L, 261L, 262L, 280L, 284L, 286L, 287L, 301L, 318L, 322L, 372L,
380L, 385L, 432L, 448L, 462L, 463L, 495L, 539L, 557L, 563L, 566L,
570L, 577L, 599L, 605L, 609L, 615L, 617L, 624L, 663L, 673L, 679L,
682L, 707L, 730L, 733L, 746L, 754L, 757L, 762L, 781L, 793L, 815L,
817L, 823L, 826L, 856L, 864L, 869L, 877L, 895L, 899L, 918L, 929L,
937L, 962L, 963L, 978L, 980L, 981L, 995L, 1004L, 1005L, 1007L,
1008L, 1012L, 1015L, 1020L, 1027L, 1055L, 1060L, 1078L, 1079L,
1084L)
, class = "data.frame")
ggplot(x, aes(hour)) +
geom_bar(binwidth = 1, position = "dodge", fill = "grey") +
geom_density() +
aes(y = ..count..) +
scale_x_continuous(breaks = seq(0,24,4))
Senang bagi siapa pun dengan kosa kata statistik yang lebih baik untuk mengedit pertanyaan ini, terutama judul dan tag.