# Origin Table like below : df
Col1 Col2 Keep1 Keep2
" "";2017-01-01;2016-09-17" "201-101;201-102;201-103" John Apple
"2018-01-01;"";2012-09-17" " "";201-102;203-640" Tom Orange
"2015-04-11;2016-08-12" "301-190;302-801" Mary Banana
"2017-01-01" "401-031" Dan Beer
# Desired Table : df2
Col1 Col2 Keep1 Keep2
"" 201-101 John Apple
2017-01-01 201-102 John Apple
2016-09-17 201-103 John Apple
2018-01-01 "" Tom Orange
"" 201-102 Tom Orange
2012-09-17 203-640 Tom Orange
2015-04-11 301-190 Mary Banana
2016-08-12 302-801 Mary Banana
2017-01-01 401-031 Dan Beer
Targeted Split Columns have same numbers of elements in one cell connected by " ; ".
Want to split them parallelly :
- Col1 1st Element -- Col2 1st Element
- Col1 2nd Element -- Col2 2nd Element
- Col1 3rd Element -- Col2 3rd Element
while copying the others cols .
library(tidyverse)
separate_rows
exactly perform this but ,
- Col1 1st Element -- Col2 1st Element ,2nd Element , 3rd Element
- Col1 2st Element -- Col2 1st Element ,2nd Element , 3rd Element
- Col1 3st Element -- Col2 1st Element ,2nd Element , 3rd Element....
it is copying all the patterns when specify multi cols to split .
How to splitting multi cols while arranging them in way corresponding to every element ?
- "" in the dataset exactly means "" like what R console display , they can only be detected by grepl("",x) or < 0 , < 1 .Not Null,Na,NaN ,\n,\s .e.t.c. This issue also drive me crazy .