728x90
반응형
숫자로 된 범주형 자료
- 숫자 형태의 범주형 자료도(명목 척도) 문자 형태의 범주형 자료와 마찬가지로 도수분포를 계산한 후 막대그래프와 원그래프를 그려서 자료의 내용을 확인
- 학생 15명이 선호하는 색깔을 조사한 자료
더보기
# 숫자로 된 범주형 자료
favorite.color <- c(2,3,2,1,1,1,2,2,1,3,2,1,3,2,1,2)
bar_graph <- table(favorite.color)
bar_graph
barplot(bar_graph, main='favorite.color')
colors <- c('green','orange','blue')
names(bar_graph) <- colors # 자료값 1,2,3을 green, orange, blue로 변경
bar_graph
barplot(bar_graph, main="favorite.color", col = colors) # 색 지정 막대 그래프
pie(bar_graph, main = 'favorite.color',col = colors) # 색 지정 원 그래프
R에 적용 가능한 색상
출처 : http://www.stat.auckland.ac.nz/~ihaka/courses/787/R-colours-a4.pdf
기본 색상
명도 별
회색 계열
출처 : 모두를 위한 R 데이터 분석 입문 한빛아카데미
728x90
반응형