Responsible Visualization

Jun

2020-03-19


개요

이번에는 깃허브에 있는 Contribution 그래프를 R에서 반응형 그래프로 시각화해볼 것이다.

Github Code: Jun4871 Github

라이브러리 활성화

먼저 작업에 필요한 패키지들을 불러오도록 하자.

## Loading required package: xml2
## ── Attaching packages ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── tidyverse 1.3.0 ──
## ✓ ggplot2 3.2.1     ✓ purrr   0.3.3
## ✓ tibble  2.1.3     ✓ dplyr   0.8.3
## ✓ tidyr   1.0.0     ✓ stringr 1.4.0
## ✓ readr   1.3.1     ✓ forcats 0.4.0
## ── Conflicts ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter()         masks stats::filter()
## x readr::guess_encoding() masks rvest::guess_encoding()
## x dplyr::lag()            masks stats::lag()
## x purrr::pluck()          masks rvest::pluck()
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout

URL 주소 할당

깃허브에 있는 주소를 캐릭터화 시켜서 객체에 할당시켜준다.

자료 추출

함수를 사용하여 홈페이지로부터 자료를 추출한다. 각 함수의 의미는 다음과 같다.


  • read_html() : 해당 url의 html 소스코드를 가져옴
  • html_nodes() : 해당 태그가 포함하고 있는 소스코드 및 속성을 추출함
  • html_attr() : 해당 속성의 값을 추출함

시각화

전처리한 데이터를 가지고 ggplot을 이용해 반응형 그래프를 생성해보았다.