library(gantt)
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
options(width = 800)

Introduction

Gantt is a package to create Gantt charts. This are used for scheduling purposes in project management. As different project managers has different needs, this packages offers variety of options to customize charts in very easy way. This document covers how to create charts and deeply walks through styling modifications.

Installation and loading

You can easily install and load package to your R session by executing following commands.

# install.packages("devtools")
devtools::install_github("piotr-ole/gantt")
library(gantt)

Define your tasks

At the beginning, there is a need to gather your tasks into csv file. Each row should contain tasks in order you want to plot it on a gantt chart. The following columns should be included:

Example task file should have following structure

library(gantt)
library(knitr)
file_path <- system.file("extdata", "example_task_1.csv", package = "gantt")
kable(read.csv(file_path, sep = ';'))

Create task data.frame

As you created CSV file with tasks specification, you can read it into R with read_task() function. In the next examples, the 'example_task_1.csv' will be used which comes with the package.

file_path <- system.file("extdata", "example_task_1.csv", package = "gantt")
task <- gantt::read_task(task_file = file_path, delimiter = ';', date_format = '%d/%m/%Y')

The delimiter and date_format has default values as in the example, in the other cases they should be specified.

Create styling list

Next step is to create list with styling parameters, which will be used to draw a Gantt chart. You can do it with create_gantt_config() function by passing parameters as arguments. Function comes with predefined values of all arguments so they do not have to be specified. Later we will explore how changes of parameters affect the plot.

conf <- gantt::create_gantt_config()

Draw Gantt chart

Now drawing a Gantt chart is very simple, you have to execute gantt() function with task and conf as arguments.

gantt::gantt(task = task, conf = conf)

Exploring styles

Here, some cases with different styles will be shown. To view list of all styling options with detailed informations visit create_gantt_config manual.

Case #1

Requirements:

conf <- gantt::create_gantt_config(stage_path = TRUE, control_path = FALSE,
                                   y_axis_color_by_stages = FALSE,
                                   task_bar_color = 'stage')
gantt::gantt(task = task, conf = conf)

Case #2

Requirements:

conf <- gantt::create_gantt_config(x_axis_text_size = 12,
                                   stage_path = FALSE, control_path = FALSE,
                                   stage_arrows = FALSE
                                   )
gantt::gantt(task = task, conf = conf)

Case #3

Requirements:

conf <- gantt::create_gantt_config(plot_title = 'App development schedule', plot_title_size = 15,
                                   stage_path = TRUE, control_path = TRUE,
                                   x_axis_label_position = 'top'
                                   )
gantt::gantt(task = task, conf = conf)


piotr-ole/gantt documentation built on Jan. 27, 2020, 5:01 a.m.