R을 이용한 일정표, 스케줄 테이블 만들기 [vistime]
회사에서 과제를 진행하다보면 일정표를 많이 작성하게 된다. 엑셀로도 만들지만 대부분 PPT를 이용하여 아래와 같이 한장으로 만든다.
그런데 이런 표들을 만들다보면 글씨 크기와 색깔, 화살표등을 만드는 것이 쉽지 않다. R을 이용해서 이런 일정표를 만들 수는 없을까 찾아보니 좋은 패키지를 찾았다.
"vistime" https://cran.r-project.org/web/packages/vistime/index.html
CRAN - Package vistime
vistime: Pretty Timelines in R A library for creating time based charts, like Gantt or timelines. Possible outputs include 'ggplot2' diagrams, 'plotly.js' graphs, 'Highcharts.js' widgets and data.frames. Results can be used in the 'RStudio' viewer pane, in
cran.r-project.org
그럼 본격적으로 이걸 이용해서 자주 사용하는 일정표를 만들어보자
우선 엑셀에 아래와 같이 작성해본다.
Name | Group | start_year | end_year |
PA | Main 과제 | 2024-01-01 | 2024-01-31 |
EA | Main 과제 | 2024-02-01 | 2024-03-31 |
ER1 | Main 과제 | 2024-04-01 | 2024-08-31 |
ER2 | Main 과제 | 2024-09-01 | 2024-12-31 |
CA | Main 과제 | 2025-01-01 | 2025-01-31 |
재료 개발 | sub 과제1 | 2024-03-01 | 2024-06-30 |
설비 개조 | sub 과제2 | 2024-05-01 | 2024-08-31 |
양산라인 평가 | sub 과제3 | 2024-09-01 | 2024-12-31 |
Simulation | Events | 2024-04-30 | |
MTO | Events | 2024-05-31 | |
단막 평가 | Events | 2024-09-30 | |
패널 평가 | Events | 2024-10-31 | |
광특성 확보 | Events | 2024-12-31 |
그리고 나서 이걸 ctrl+c 로 복사 한 후 R에서 addins -> Pasta as tribble 로 붙여넣는다. (datapasta 패키지 설치)
df <- tibble::tribble(
~Name, ~Group, ~start_year, ~end_year,
"PA", "Main 과제", "2024-01-01", "2024-01-31",
"EA", "Main 과제", "2024-02-01", "2024-03-31",
"ER1", "Main 과제", "2024-04-01", "2024-08-31",
"ER2", "Main 과제", "2024-09-01", "2024-12-31",
"CA", "Main 과제", "2025-01-01", "2025-01-31",
"재료 개발", "sub 과제1", "2024-03-01", "2024-06-30",
"설비 개조", "sub 과제2", "2024-05-01", "2024-08-31",
"양산라인 평가", "sub 과제3", "2024-09-01", "2024-12-31",
"Simulation", "Events", "2024-04-30", NA,
"MTO", "Events", "2024-05-31", NA,
"단막 평가", "Events", "2024-09-30", NA,
"패널 평가", "Events", "2024-10-31", NA,
"광특성 확보", "Events", "2024-12-31", NA
)
그리고 나서 패키지 설치 및 불러오기
library(tidyverse)
library(vistime)
그러면 그래프로 시각화를 해보자 (그러면 기본적으로 Plotly 로 그래프가 그려진다.)
p <- vistime(df,
col.start = "start_year",
col.end = "end_year",
col.event = "Name",
col.group = "Group",
title = "N+1 과제 Milestone")
Plotly 의 맛을 느낄 수 있도록 html로 저장해서 표시해보면 어떨까?
saveWidget(p, "p1.html", selfcontained = F, libdir = "lib")
https://posit.cloud/content/7902634
Posit Cloud - Do, share, teach, and learn data science
posit.cloud