For a data.frame containing a column with (some) multiple failure modes, this function expands the data.frame by repeating each row with multiple failure modes so that each row contains only a single failure mode.

separate_failure_modes(data, failure_mode, sep = "[/, ]+")

Arguments

data

a data.frame

failure_mode

the column in data containing the failure modes

sep

a regular expression with the character(s) separating individual failure modes. Default "[/, ]+".

Details

When multiple failure modes are reported, they are commonly reported in the format "LGM/GIT" or "LGM,GIT". This function will separate these multiple failure modes into multiple rows.

This can be useful when counting the number of coupons exhibited each failure mode.

Examples

library(dplyr)
data.frame(strength = c(101, 102), fm = c("LGM/GIT", "LGM")) %>%
  separate_failure_modes(fm)
#> # A tibble: 3 × 2
#>   strength fm   
#>      <dbl> <chr>
#> 1      101 LGM  
#> 2      101 GIT  
#> 3      102 LGM  
##
## # A tibble: 3 × 2
##   strength fm
##      <dbl> <chr>
## 1      101 LGM
## 2      101 GIT
## 3      102 LGM