I have a dataset in which some columns have multiple values that are separated with ";" and some columns only have single values. I am trying to kinda split these into multiple rows, while preserving the ones that have single values. I have already tried to use separate_rows in a loop fashion:
cols <- colnames(df) for(col in cols) { print(col) df <- separate_rows_(df, col,sep = ";") df <- df %>% mutate(across(where(is.character), str_trim)) df <- unique(df) gc() }
However, this somehow gives me wrong combinations of values. What I am trying to achieve is actually this:
Comparable post but with excel: How do I separate a row with delimited values into individual rows?
Thanks