histogram
Histogram | Bar graph (stat = “count”) | Bar graph (stat = “identity”) | |
type of data | 연속형 (numerical data) int, number | 이산형 (categorical data) factor | Frequency Table |
X | X | X, Y | |
indicate | 분포 | 비교 | 표시 |
elements | 범위에 따라 grouping | 각 bin를 이룬다. | 각 bin는 y값 |
reorder | 불가능 | 가능 | 가능 |
bar width | 같을 필요없다. | 항상 같다. | 항상 같다. |
bins vs. binwidth
한 변수(X)의 구간별 빈도수를 나타낸 그래프
구간은 일반적으로 등간격으로 나누기 때문에, 구간의 넓이/폭/interval (or 갯수)가 중요하다.
– bins : 표현할 막대 갯수
– binwidth: 막대를 나누는 단위 기준
bins : 표현할 막대 갯수
R
binwidth: 막대를 나누는 단위 기준
R


0.8~1.0~1.2
1.3~1.5~1.7
1.8~2.0

0.6~1~1.5
1.5~2~
geom_histogram
R
등간격이 밑면이 1일때, 각 bin의 높이는 비율.
counts/ (n*diff(breaks))
R
예제데이터 (100m달리기 선수 기록, 2019년)
R
R

R

위에서 (9초를 기준으로) 선수 0.01초 간격으로 histogram을 그렸다.
bar와 다르게 histgram은 0.05초 기준으로 그려볼 수 도 있고, 각 bin의 넓이를 다르게 지정할 수도 있다.
R

R

color with cut()
https://www.r-bloggers.com/pretty-histograms-with-ggplot2/
R




R
https://ggplot2.tidyverse.org/reference/geom_histogram.html
R




R
R
Hist
R

R
R
R
geom_bar
stat = “count” vs “identity”
R


Histogram | Bar graph (stat = “count”) | Bar graph (stat = “identity”) | |
type of data | 연속형 (numerical data) int, number | 이산형 (categorical data) factor | Frequency Table |
X | X | X, Y | |
indicate | 분포 | 비교 | 표시 |
elements | 범위에 따라 grouping | 각 bin를 이룬다. | 각 bin는 y값 |
reorder | 불가능 | 가능 | 가능 |
bar width | 같을 필요없다. | 항상 같다. | 항상 같다. |
R