0

I have a data frame with a vector that has multiple combinations of strings separated by a delimiter ";" without any sequential order to the strings in that vector. I would like to know if there is a way to separate the strings in that vector by the delimiter into multiple unique vectors (dummy variables) with names that correspond to each of the unique strings.

The following sample is from a data frame with >100k rows:

structure(list(Error = structure(1:4, .Label = c("Caller Relationship;Incorrect Department;Incorrect Location", "Facility Information;Incorrect Department", "Incident Date", "Information;IVR"), class = "factor")), .Names = "Error", class = "data.frame", row.names = c(NA, -4L))

The result I need is:

structure(list(Error = structure(1:4, .Label = c("Caller Relationship;Incorrect Department;Incorrect Location", "Facility Information;Incorrect Department", "Incident Date", "Information;IVR"), class = "factor"), Caller.Relationship = c(1L, NA, NA, NA), Incorrect.Department = c(1L, 1L, NA, NA), Incorrect.Location = c(1L, NA, NA, NA), Facility.Information = c(NA, 1L, NA, NA), Incident.Date = c(NA, NA, 1L, NA), Information = c(NA, NA, NA, 1L), IVR = c(NA, NA, NA, 1L)), .Names = c("Error", "Caller.Relationship", "Incorrect.Department", "Incorrect.Location", "Facility.Information", "Incident.Date", "Information", "IVR"), class = "data.frame", row.names = c(NA, -4L))
user3594490
  • 1,949
  • 2
  • 20
  • 26

0 Answers0