# [1] 건강보험심사평가원 보건의료빅데이터 개방시스템
# http://opendata.hira.or.kr/home.do# 18,000여개의 관찰치와 8개의 변수가 있는 대장암 환자데이터를 통해# 가장 많은 대장암이 발생하는 연령대를 그래프로 표현하시오.

우리나라 대장암 발생 연령대 분석자료

1단계 : 데이터 로딩

ver.cancer <- read.csv('https://www.dropbox.com/s/dw59m4q1vaqwayl/example_cancer.csv?dl=1')

2단계 : 데이터 구조

str(ver.cancer)
## 'data.frame':    18310 obs. of  8 variables:
##  $ age            : int  75 52 67 62 70 76 55 72 64 71 ...
##  $ sex            : Factor w/ 2 levels "남","여": 1 2 2 1 1 2 1 1 1 1 ...
##  $ height         : Factor w/ 485 levels "100","130","130.2",..: 252 408 182 262 352 352 467 165 172 232 ...
##  $ weight         : Factor w/ 638 levels "100","101","101.1",..: 333 446 349 263 343 563 463 243 363 248 ...
##  $ dateOfoperation: Factor w/ 351 levels "2011-01-02","2011-01-03",..: 165 134 146 164 154 160 164 147 219 192 ...
##  $ cancerStaging  : Factor w/ 5 levels "I","II","III",..: 1 4 3 1 2 3 2 3 1 2 ...
##  $ hospitalization: int  48 17 10 11 10 10 12 18 15 35 ...
##  $ diseaseCode    : Factor w/ 13 levels "C18","C180","C181",..: 9 9 9 9 4 11 9 4 13 11 ...

3단계 : 연령대별 도수값

ver.degree_of_age <- table(cut(ver.cancer$age, breaks = (1:11)*10))

4단계 : 열값의 이름 변경

head(ver.degree_of_age)
## 
## (10,20] (20,30] (30,40] (40,50] (50,60] (60,70] 
##       3      77     482    1917    4558    5679
rownames(ver.degree_of_age) <- c('10대','20대','30대','40대','50대','60대','70대','80대',
                                 '90대','100대')

5단계 : 시각화차트

library(ggplot2)
## Warning: package 'ggplot2' was built under R version 3.5.1
library(ggthemes)

ggplot(data = ver.cancer, aes(x=age))+geom_freqpoly(binwidth=10, size=1.4, coloer='orange')+
  theme_wsj()
## Warning: Ignoring unknown parameters: coloer