Gantt doesn look corect

I want to see the intreuption for one machine in two shift .Below are the data :slight_smile:

shift start end
1 23-12-2021 7:09 23-12-2021 7:10
1 23-12-2021 7:10 23-12-2021 7:10
1 23-12-2021 7:15 23-12-2021 7:15
1 23-12-2021 7:30 23-12-2021 7:37
1 23-12-2021 7:37 23-12-2021 7:40
1 23-12-2021 8:57 23-12-2021 9:00
1 23-12-2021 9:03 23-12-2021 9:04
1 23-12-2021 9:17 23-12-2021 9:18
1 23-12-2021 9:39 23-12-2021 9:39
1 23-12-2021 9:50 23-12-2021 9:51
1 23-12-2021 10:00 23-12-2021 10:30
1 23-12-2021 10:30 23-12-2021 10:32
1 23-12-2021 11:41 23-12-2021 11:42
1 23-12-2021 13:01 23-12-2021 13:02
1 23-12-2021 13:14 23-12-2021 13:16
1 23-12-2021 13:21 23-12-2021 13:21
1 23-12-2021 13:25 23-12-2021 13:27
1 23-12-2021 13:35 23-12-2021 13:35
1 23-12-2021 13:44 23-12-2021 13:44
1 23-12-2021 13:45 23-12-2021 13:45
1 23-12-2021 13:49 23-12-2021 13:55
2 23-12-2021 13:57 23-12-2021 14:08
2 23-12-2021 14:09 23-12-2021 14:12
2 23-12-2021 14:29 23-12-2021 14:29
2 23-12-2021 15:15 23-12-2021 15:16
2 23-12-2021 15:41 23-12-2021 15:42
2 23-12-2021 15:51 23-12-2021 15:53
2 23-12-2021 16:13 23-12-2021 16:13
2 23-12-2021 16:33 23-12-2021 16:34
2 23-12-2021 16:38 23-12-2021 16:38
2 23-12-2021 16:41 23-12-2021 16:43
2 23-12-2021 17:01 23-12-2021 17:02
2 23-12-2021 17:11 23-12-2021 17:11
2 23-12-2021 17:31 23-12-2021 17:33
2 23-12-2021 17:43 23-12-2021 17:44
2 23-12-2021 17:49 23-12-2021 17:49
2 23-12-2021 17:55 23-12-2021 18:25
2 23-12-2021 18:25 23-12-2021 18:28
2 23-12-2021 18:30 23-12-2021 18:52
2 23-12-2021 18:54 23-12-2021 19:07
2 23-12-2021 19:07 23-12-2021 19:07
2 23-12-2021 19:08 23-12-2021 19:14
2 23-12-2021 19:15 23-12-2021 19:20
2 23-12-2021 19:54 23-12-2021 19:56
2 23-12-2021 20:02 23-12-2021 20:03
2 23-12-2021 20:08 23-12-2021 20:08
2 23-12-2021 20:18 23-12-2021 20:20
2 23-12-2021 20:22 23-12-2021 20:26
2 23-12-2021 20:55 23-12-2021 21:00
2 23-12-2021 21:21 23-12-2021 21:24
2 23-12-2021 21:31 23-12-2021 21:31
2 23-12-2021 21:37 23-12-2021 21:37
2 23-12-2021 21:54 23-12-2021 21:55
2 23-12-2021 21:55 23-12-2021 21:57

library(ggplot2)
library(readr)
activities <- read_csv("d://temp/Proiecte R/stati.csv")
## Set factor level to order the activities on the plot
activities$shift <- factor(activities$shift,
                              levels = activities$shift[nrow(activities):1])

plot_gantt <- qplot(ymin = start,
                    ymax = end,
                    x = shift,
                    colour = shift,
                    geom = "linerange",
                    data = activities,
                    size = I(5)) +
 
  coord_flip() +
  theme_bw() +
  theme(panel.grid = element_blank()) +
  xlab("") +
  ylab("") +
  ggtitle("Intreruption")
plot_gantt

If I convert the start and end columns to POSIXct using the lubridate column, I get a plot that looks as I would expect.

library(ggplot2)
library(lubridate)
#> 
#> Attaching package: 'lubridate'
#> The following objects are masked from 'package:base':
#> 
#>     date, intersect, setdiff, union
library(readr)
activities <- read_csv("~/R/Play/Dummy.csv")
#> Rows: 54 Columns: 3
#> -- Column specification --------------------------------------------------------
#> Delimiter: ","
#> chr (2): start, end
#> dbl (1): shift
#> 
#> i Use `spec()` to retrieve the full column specification for this data.
#> i Specify the column types or set `show_col_types = FALSE` to quiet this message.
activities$start <- dmy_hm(activities$start)
activities$end <- dmy_hm(activities$end)
activities$shift <- factor(activities$shift)#,
                           #levels = activities$shift[nrow(activities):1])

plot_gantt <- qplot(ymin = start,
                    ymax = end,
                    x = shift,
                    colour = shift,
                    geom = "linerange",
                    data = activities,
                    size = I(5)) +
  
  coord_flip() +
  theme_bw() +
  theme(panel.grid = element_blank()) +
  xlab("") +
  ylab("") +
  ggtitle("Intreruption")
plot_gantt

Created on 2021-12-24 by the reprex package (v2.0.1)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.