Split column content into multiple columns

A way to address this problem is to clean the text first and then use tidyr::separate(). I'm going to give you an example with just the line you mentioned since the link you provided doesn't inspire much trust (it is not very likely people are going to download it).

library(tidyverse)

# Sample data in a copy/paste friendly format, use your own data frame instead
sample_df <- tibble::tribble(
    ~sample_text,
    "Acute respiratory failure (2d - Fatal - Results in Death, Caused/Prolonged Hospitalisation),"
)

sample_df %>% 
    mutate(sample_text = str_replace(sample_text, "\\(", "- "),
           sample_text = str_remove(sample_text, "\\),")) %>% 
    separate(sample_text,
             into = c("Reaction_List_PT", "Duration",
                      "Outcome", "Seriousness_criteria"),
             sep = " - ")
#> # A tibble: 1 Ă— 4
#>   Reaction_List_PT          Duration Outcome Seriousness_criteria               
#>   <chr>                     <chr>    <chr>   <chr>                              
#> 1 Acute respiratory failure 2d       Fatal   Results in Death, Caused/Prolonged…

Created on 2023-01-15 with reprex v2.0.2

If you need more specific help, please provide a proper REPRoducible EXample (reprex) illustrating your issue.

1 Like