I have the datset below. I provide only 50 rows even though the issue begins from 1000 rows and later but then the dataset is too big to display it here.
pr59<- structure(list(case_id = c("WC4120721", "WC4120667", "WC4120689",
"WC4121068", "WC4120667", "WC4120666", "WC4120667", "WC4121068",
"WC4120667", "WC4121068", "WC4121068", "WC4120666", "WC4120721",
"WC4120666", "WC4120666", "WC4120721", "WC4121068", "WC4120721",
"WC4120667", "WC4121354", "WC4121068", "WC4120666", "WC4121354",
"WC4121354", "WC4121354", "WC4120721", "WC4120667", "WC4121068",
"WC4121483", "WC4121655", "WC4121354", "WC4121011", "WC4121302",
"WC4121781", "WC4120958", "WC4120721", "WC4121352", "WC4121211",
"WC4121354", "WC4121405", "WC4121569", "WC4121661", "WC4121328",
"WC4121808", "WC4121494", "WC4120689", "WC4121859", "WC4121833",
"WC4121834", "WC4121360"), lifecycle = c(110, 110, 110, 110,
120, 110, 130, 120, 10, 130, 10, 120, 120, 130, 10, 130, 15,
10, 20, 110, 30, 0, 120, 130, 10, 30, 0, 0, 110, 110, 20, 110,
110, 110, 110, 0, 110, 110, 0, 110, 110, 110, 110, 110, 110,
10, 110, 110, 15, 110), action = c("WC4120721-CN354877", "WC4120667-CN354878",
"WC4120689-CN356752", "WC4121068-CN301950", "WC4120667-CSW310",
"WC4120666-CN354878", "WC4120667-CSW308", "WC4121068-CSW303",
"WC4120667-CSW309", "WC4121068-CSW308", "WC4121068-CSW309", "WC4120666-CSW310",
"WC4120721-CSW310", "WC4120666-CSW308", "WC4120666-CSW309", "WC4120721-CSW308",
"WC4121068-CSW404", "WC4120721-CSW309", "WC4120667-CSW404", "WC4121354-CN354927",
"WC4121068-CSW421", "WC4120666-C-SUB-DT", "WC4121354-CSW303",
"WC4121354-CSW308", "WC4121354-CSW309", "WC4120721-CSW404", "WC4120667-CSW415",
"WC4121068-CSW415", "WC4121483-CN356753", "WC4121655-CN301288",
"WC4121354-CSW404", "WC4121011-CN358282", "WC4121302-CN301294",
"WC4121781-CN354089", "WC4120958-CN353543", "WC4120721-CSW415",
"WC4121352-CN355038", "WC4121211-CSW270", "WC4121354-CSW410",
"WC4121405-CN354751", "WC4121569-CSW270", "WC4121661-CN301287",
"WC4121328-CN355026", "WC4121808-CN303310", "WC4121494-CN354545",
"WC4120689-CSW304", "WC4121859-CN354089", "WC4121833-CN303318",
"WC4121834-CSW404", "WC4121360-CN356995"), activity = c("Forged Wire, Medium (Sport)",
"Forged Wire, Medium (Sport)", "Forged Wire, Medium (Sport)",
"Forged Wire, Medium (Sport)", "BBH-1&2", "Forged Wire, Medium (Sport)",
"TCE Cleaning", "SOLO Oil", "Tempering", "TCE Cleaning", "Tempering",
"BBH-1&2", "BBH-1&2", "TCE Cleaning", "Tempering", "TCE Cleaning",
"CPL", "Tempering", "CPL", "Forged Wire, Medium (Sport)", "TCE for Lacquering",
"Subcontracting Duratin", "SOLO Oil", "TCE Cleaning", "Tempering",
"CPL", "Lacquering", "Lacquering", "Forged Wire, Medium (Sport)",
"Needle Point", "CPL", "Needle Point", "Needle Point", "Brazing Machines",
"Brazing Machines", "Lacquering", "Forged Wire, Medium (Sport)",
"Big Manual", "Nickel Barel", "Forged Wire, Medium (Sport)",
"Big Manual", "Needle Point", "Forged Wire, Medium (Sport)",
"Brazing Machines", "Forged Wire, Large (Sport)", "SOLO Salt",
"Brazing Machines", "Brazing Machines", "CPL", "Forged Wire, Medium (Sport)"
), resource = c("3419", "3216", "3409", "3201", "C3-100", "3216",
"C3-080", "C3-030", "C3-090", "C3-080", "C3-090", "C3-100", "C3-100",
"C3-080", "C3-090", "C3-080", "C4-040", "C3-090", "C4-040", "3210",
"C4-210", NA, "C3-030", "C3-080", "C3-090", "C4-040", "C4-150",
"C4-155", "3205", "5417", "C4-040", "5501", "5201", "7748", "7725",
"C4-150", "3206", NA, "C4-100", "3403", NA, "5417", "3206", "7714",
"3107", "C3-040", "7748", "7708", "C4-040", "3203"), timestamp = structure(c(-62042010952,
-62010323872, -61884118792, -61821087232, -61821025132, -61789534972,
-61789520332, -61789494952, -61757940232, -61757925652, -61757895952,
-61694827552, -61694808292, -61663337152, -61663307452, -61663297792,-61663267192, -61631716792, -61631705632, -61631702212, -61631699992,
-61631652052, -61568570152, -61537087252, -61537057552, -61505477992,
-61442400112, -61442396992, -61442357152, -61410876172, -61410862072,
-61410799072, -61379220292, -61347689452, -61347639772, -61316169592,
-61316168872, -61316168032, -61316164552, -61284589912, -61253008912,
-61253007532, -61252996012, -61252962832, -61252942252, -61221457852,
-61221449332, -61221416572, -61221411472, -61189947712), tzone = "Europe/Istanbul", class = c("POSIXct",
"POSIXt")), .order = 1:50), row.names = c(NA, -50L), class = c("eventlog",
"log", "tbl_df", "tbl", "data.frame"), case_id = "case_id", activity_id = "activity", activity_instance_id = "action", lifecycle_id = "lifecycle", resource_id = "resource", timestamp = "timestamp")
From here I try:
library(processmapR)
library(bupaR)
pr59 %>% dotted_chart(x = "absolute", y = "start") %>%plot
and with the 1000 rows dataset I get:
Insufficient values in manual scale. 45 needed but only 35 provided.
Run `rlang::last_error()` to see where the error occurred.
Then I try to create and pass my own palette with as many colors as needed:
# count the needed levels of a factor
number <- length(unique(pr59$activity))
library(RColorBrewer)
n <- number
qual_col_pals = brewer.pal.info[brewer.pal.info$category == 'qual',]
col_vector = unlist(mapply(brewer.pal, qual_col_pals$maxcolors, rownames(qual_col_pals)))
pr59 %>% dotted_chart(x = "absolute", y = "start") %>%plot
scale_fill_manual(values=col_vector[1:number])
but still get the same error.
CodePudding user response:
This is a hack solution inspired by : https://stat.ethz.ch/pipermail/r-help/2008-August/171291.html
In this hack I show how I can dictate the (in this example case) 15 colour values utilised.
I would recommend that the proper way to address this is to raise an issue on the appropriate github issue tracker at https://github.com/bupaverse/processmapR/issues
library(processmapR)
col_vector <- function() rep(c("red","green","blue"),5)
unlockBinding("col_vector", getNamespace("processmapR"))
assign("col_vector", col_vector, getNamespace("processmapR"))
dotted_chart(pr59,x = "absolute", y = "start")