Feature Requests:

  1. a time variable and business rules based on date times;

  2. step grouping (IE: step1, step2, step3 = phase1; step4, step5 = phase2; etc.). Takes a dataframe column you want to group by, and a column you want to make a pathway out of and returns a pathway vector the size of your original data. Used when you want to know unique combinations of steps in order to count or group by. A medical pathway or business process steps are good use cases.

makepath(groupcol, pathcol, sep = "-", subset = FALSE, keepvalues,
  ordered = TRUE, keepconsec = TRUE, n.cores = detectCores() - 1)

Arguments

groupcol

The column you want to group by. Generally it's a person or employee.

pathcol

The column you want to create a path from. IE: service_type, location, step

sep

The seperator that goes between the parts of the pathway. The default is hyphen (-).

subset

A boolean flag to indicate if you want to use every possible part/step in the pathway or if you just want to track certain steps. Default is FALSE (use all values). Must use the keepvalues parameter if the subset flag is TRUE (use certain values).

keepvalues

A character vector of the pathway parts/steps you want to use. Only use when the subset flag is TRUE.

ordered

A boolean flag to indicate whether or not the path should care about occurence order (when the step occured). Default is TRUE. If flag is set to FALSE the pathway vector will be sorted alphabetically.

keepconsec

A boolean flag to indicate if you want to keep or remove duplicated steps in the pathway. Default is TRUE.

n.cores

An integer value that indicates the number of cores you want to run the process on. The default is 1 less than the total number of available cores on the CPU for UNIX flavored OSs, while the only option (currently) on Windows OS is 1.

Examples

asd <- data.frame( id = rep(letters, times = 4) , service = sample( c('ps1', 'ps2', 'ps3', 'ps4', 'ps5', 'ps6', 'ps7' , 'install1', 'install2', 'install3', 'other' ) , size = 26 * 4 , replace = TRUE ) , stringsAsFactors = FALSE ) asd$path1 <- makepath( groupcol = asd$id , pathcol = asd$service , n.cores = 1 ) asd$path2 <- makepath( groupcol = asd$id , pathcol = asd$service , subset = TRUE , keepvalues = c('ps1', 'ps2', 'ps3') , n.cores = 1 ) asd$path3 <- makepath( groupcol = asd$id , pathcol = asd$service , subset = TRUE , keepvalues = c('ps1', 'ps2', 'ps3') , ordered = FALSE , n.cores = 1 ) asd$path4 <- makepath( groupcol = asd$id , pathcol = asd$service , subset = TRUE , keepvalues = c('ps1', 'ps2', 'ps3') , ordered = FALSE , keepconsec = TRUE , n.cores = 1 ) asd
#> id service path1 path2 path3 #> 1 a install1 install1-ps3-ps1-other ps3-ps1 ps1-ps3 #> 2 b install3 install3-ps6-install3-ps3 ps3 ps3 #> 3 c other other-other-ps2-install2 ps2 ps2 #> 4 d ps7 ps7-other-ps6-ps4 <NA> <NA> #> 5 e ps7 ps7-install3-ps3-install3 ps3 ps3 #> 6 f install1 install1-install3-install1-ps4 <NA> <NA> #> 7 g ps3 ps3-ps7-ps2-other ps3-ps2 ps2-ps3 #> 8 h ps1 ps1-install2-other-ps7 ps1 ps1 #> 9 i other other-other-ps4-install2 <NA> <NA> #> 10 j ps1 ps1-install1-ps4-install3 ps1 ps1 #> 11 k other other-ps3-install3-install2 ps3 ps3 #> 12 l ps7 ps7-ps4-install3-ps5 <NA> <NA> #> 13 m ps2 ps2-install1-ps2-ps2 ps2-ps2-ps2 ps2-ps2-ps2 #> 14 n other other-install3-install3-ps1 ps1 ps1 #> 15 o ps1 ps1-ps3-install2-install1 ps1-ps3 ps1-ps3 #> 16 p ps7 ps7-ps1-ps5-ps7 ps1 ps1 #> 17 q ps3 ps3-other-other-install1 ps3 ps3 #> 18 r install3 install3-ps5-ps4-ps4 <NA> <NA> #> 19 s install3 install3-install2-other-other <NA> <NA> #> 20 t install1 install1-install1-ps3-install1 ps3 ps3 #> 21 u ps3 ps3-ps5-ps1-install3 ps3-ps1 ps1-ps3 #> 22 v install2 install2-ps4-ps2-other ps2 ps2 #> 23 w ps3 ps3-install2-install3-ps3 ps3-ps3 ps3-ps3 #> 24 x ps6 ps6-install1-ps3-install1 ps3 ps3 #> 25 y ps4 ps4-ps1-ps3-ps5 ps1-ps3 ps1-ps3 #> 26 z ps7 ps7-install3-ps1-ps1 ps1-ps1 ps1-ps1 #> 27 a ps3 install1-ps3-ps1-other ps3-ps1 ps1-ps3 #> 28 b ps6 install3-ps6-install3-ps3 ps3 ps3 #> 29 c other other-other-ps2-install2 ps2 ps2 #> 30 d other ps7-other-ps6-ps4 <NA> <NA> #> 31 e install3 ps7-install3-ps3-install3 ps3 ps3 #> 32 f install3 install1-install3-install1-ps4 <NA> <NA> #> 33 g ps7 ps3-ps7-ps2-other ps3-ps2 ps2-ps3 #> 34 h install2 ps1-install2-other-ps7 ps1 ps1 #> 35 i other other-other-ps4-install2 <NA> <NA> #> 36 j install1 ps1-install1-ps4-install3 ps1 ps1 #> 37 k ps3 other-ps3-install3-install2 ps3 ps3 #> 38 l ps4 ps7-ps4-install3-ps5 <NA> <NA> #> 39 m install1 ps2-install1-ps2-ps2 ps2-ps2-ps2 ps2-ps2-ps2 #> 40 n install3 other-install3-install3-ps1 ps1 ps1 #> 41 o ps3 ps1-ps3-install2-install1 ps1-ps3 ps1-ps3 #> 42 p ps1 ps7-ps1-ps5-ps7 ps1 ps1 #> 43 q other ps3-other-other-install1 ps3 ps3 #> 44 r ps5 install3-ps5-ps4-ps4 <NA> <NA> #> 45 s install2 install3-install2-other-other <NA> <NA> #> 46 t install1 install1-install1-ps3-install1 ps3 ps3 #> 47 u ps5 ps3-ps5-ps1-install3 ps3-ps1 ps1-ps3 #> 48 v ps4 install2-ps4-ps2-other ps2 ps2 #> 49 w install2 ps3-install2-install3-ps3 ps3-ps3 ps3-ps3 #> 50 x install1 ps6-install1-ps3-install1 ps3 ps3 #> 51 y ps1 ps4-ps1-ps3-ps5 ps1-ps3 ps1-ps3 #> 52 z install3 ps7-install3-ps1-ps1 ps1-ps1 ps1-ps1 #> 53 a ps1 install1-ps3-ps1-other ps3-ps1 ps1-ps3 #> 54 b install3 install3-ps6-install3-ps3 ps3 ps3 #> 55 c ps2 other-other-ps2-install2 ps2 ps2 #> 56 d ps6 ps7-other-ps6-ps4 <NA> <NA> #> 57 e ps3 ps7-install3-ps3-install3 ps3 ps3 #> 58 f install1 install1-install3-install1-ps4 <NA> <NA> #> 59 g ps2 ps3-ps7-ps2-other ps3-ps2 ps2-ps3 #> 60 h other ps1-install2-other-ps7 ps1 ps1 #> 61 i ps4 other-other-ps4-install2 <NA> <NA> #> 62 j ps4 ps1-install1-ps4-install3 ps1 ps1 #> 63 k install3 other-ps3-install3-install2 ps3 ps3 #> 64 l install3 ps7-ps4-install3-ps5 <NA> <NA> #> 65 m ps2 ps2-install1-ps2-ps2 ps2-ps2-ps2 ps2-ps2-ps2 #> 66 n install3 other-install3-install3-ps1 ps1 ps1 #> 67 o install2 ps1-ps3-install2-install1 ps1-ps3 ps1-ps3 #> 68 p ps5 ps7-ps1-ps5-ps7 ps1 ps1 #> 69 q other ps3-other-other-install1 ps3 ps3 #> 70 r ps4 install3-ps5-ps4-ps4 <NA> <NA> #> 71 s other install3-install2-other-other <NA> <NA> #> 72 t ps3 install1-install1-ps3-install1 ps3 ps3 #> 73 u ps1 ps3-ps5-ps1-install3 ps3-ps1 ps1-ps3 #> 74 v ps2 install2-ps4-ps2-other ps2 ps2 #> 75 w install3 ps3-install2-install3-ps3 ps3-ps3 ps3-ps3 #> 76 x ps3 ps6-install1-ps3-install1 ps3 ps3 #> 77 y ps3 ps4-ps1-ps3-ps5 ps1-ps3 ps1-ps3 #> 78 z ps1 ps7-install3-ps1-ps1 ps1-ps1 ps1-ps1 #> 79 a other install1-ps3-ps1-other ps3-ps1 ps1-ps3 #> 80 b ps3 install3-ps6-install3-ps3 ps3 ps3 #> 81 c install2 other-other-ps2-install2 ps2 ps2 #> 82 d ps4 ps7-other-ps6-ps4 <NA> <NA> #> 83 e install3 ps7-install3-ps3-install3 ps3 ps3 #> 84 f ps4 install1-install3-install1-ps4 <NA> <NA> #> 85 g other ps3-ps7-ps2-other ps3-ps2 ps2-ps3 #> 86 h ps7 ps1-install2-other-ps7 ps1 ps1 #> 87 i install2 other-other-ps4-install2 <NA> <NA> #> 88 j install3 ps1-install1-ps4-install3 ps1 ps1 #> 89 k install2 other-ps3-install3-install2 ps3 ps3 #> 90 l ps5 ps7-ps4-install3-ps5 <NA> <NA> #> 91 m ps2 ps2-install1-ps2-ps2 ps2-ps2-ps2 ps2-ps2-ps2 #> 92 n ps1 other-install3-install3-ps1 ps1 ps1 #> 93 o install1 ps1-ps3-install2-install1 ps1-ps3 ps1-ps3 #> 94 p ps7 ps7-ps1-ps5-ps7 ps1 ps1 #> 95 q install1 ps3-other-other-install1 ps3 ps3 #> 96 r ps4 install3-ps5-ps4-ps4 <NA> <NA> #> 97 s other install3-install2-other-other <NA> <NA> #> 98 t install1 install1-install1-ps3-install1 ps3 ps3 #> 99 u install3 ps3-ps5-ps1-install3 ps3-ps1 ps1-ps3 #> 100 v other install2-ps4-ps2-other ps2 ps2 #> 101 w ps3 ps3-install2-install3-ps3 ps3-ps3 ps3-ps3 #> 102 x install1 ps6-install1-ps3-install1 ps3 ps3 #> 103 y ps5 ps4-ps1-ps3-ps5 ps1-ps3 ps1-ps3 #> 104 z ps1 ps7-install3-ps1-ps1 ps1-ps1 ps1-ps1 #> path4 #> 1 ps1-ps3 #> 2 ps3 #> 3 ps2 #> 4 <NA> #> 5 ps3 #> 6 <NA> #> 7 ps2-ps3 #> 8 ps1 #> 9 <NA> #> 10 ps1 #> 11 ps3 #> 12 <NA> #> 13 ps2-ps2-ps2 #> 14 ps1 #> 15 ps1-ps3 #> 16 ps1 #> 17 ps3 #> 18 <NA> #> 19 <NA> #> 20 ps3 #> 21 ps1-ps3 #> 22 ps2 #> 23 ps3-ps3 #> 24 ps3 #> 25 ps1-ps3 #> 26 ps1-ps1 #> 27 ps1-ps3 #> 28 ps3 #> 29 ps2 #> 30 <NA> #> 31 ps3 #> 32 <NA> #> 33 ps2-ps3 #> 34 ps1 #> 35 <NA> #> 36 ps1 #> 37 ps3 #> 38 <NA> #> 39 ps2-ps2-ps2 #> 40 ps1 #> 41 ps1-ps3 #> 42 ps1 #> 43 ps3 #> 44 <NA> #> 45 <NA> #> 46 ps3 #> 47 ps1-ps3 #> 48 ps2 #> 49 ps3-ps3 #> 50 ps3 #> 51 ps1-ps3 #> 52 ps1-ps1 #> 53 ps1-ps3 #> 54 ps3 #> 55 ps2 #> 56 <NA> #> 57 ps3 #> 58 <NA> #> 59 ps2-ps3 #> 60 ps1 #> 61 <NA> #> 62 ps1 #> 63 ps3 #> 64 <NA> #> 65 ps2-ps2-ps2 #> 66 ps1 #> 67 ps1-ps3 #> 68 ps1 #> 69 ps3 #> 70 <NA> #> 71 <NA> #> 72 ps3 #> 73 ps1-ps3 #> 74 ps2 #> 75 ps3-ps3 #> 76 ps3 #> 77 ps1-ps3 #> 78 ps1-ps1 #> 79 ps1-ps3 #> 80 ps3 #> 81 ps2 #> 82 <NA> #> 83 ps3 #> 84 <NA> #> 85 ps2-ps3 #> 86 ps1 #> 87 <NA> #> 88 ps1 #> 89 ps3 #> 90 <NA> #> 91 ps2-ps2-ps2 #> 92 ps1 #> 93 ps1-ps3 #> 94 ps1 #> 95 ps3 #> 96 <NA> #> 97 <NA> #> 98 ps3 #> 99 ps1-ps3 #> 100 ps2 #> 101 ps3-ps3 #> 102 ps3 #> 103 ps1-ps3 #> 104 ps1-ps1