Sorry for such silly question. I have a df that looks like this:
I want to split tx with data.frame(do.call("rbind", strsplit(as.character(df$tx), "\\s{2,}" )), stringsAsFactors=FALSE) , how can I keep Form in the new df? Also, how can i avoid the split results auto fill if it is empty?
sample df can be build using:
df<- structure(list(tx = c(" [1] Timepoint EGTMPT Categorical select one (nominal) 51 Screening",
" [2] N/A : O ff-Study EGTNA Categorical yes/no (dichotomous) 3",
" [3] Check if Not Done EGTMPTND Categorical yes/no (dichotomous) 3",
" [4] Date Performed ECGDT Date 11",
" [5] Time (24-hour format) ECGTM Time 5",
" [6] O verall ECG Interpretation ECGRES Categorical select one (nominal) 37 Normal"
), Form = c("12-Lead Electrocardiogram (EG) at Log Pages (Dosing, ECG, PBMC, Biomarkers, PK)",
"12-Lead Electrocardiogram (EG) at Log Pages (Dosing, ECG, PBMC, Biomarkers, PK)",
"12-Lead Electrocardiogram (EG) at Log Pages (Dosing, ECG, PBMC, Biomarkers, PK)",
"12-Lead Electrocardiogram (EG) at Log Pages (Dosing, ECG, PBMC, Biomarkers, PK)",
"12-Lead Electrocardiogram (EG) at Log Pages (Dosing, ECG, PBMC, Biomarkers, PK)",
"12-Lead Electrocardiogram (EG) at Log Pages (Dosing, ECG, PBMC, Biomarkers, PK)"
)), row.names = c(NA, 6L), class = "data.frame")
the output will looks like this:

Update: How should I separate tx in a better way. My old codes seems generate errors. The sample data is:
df<-structure(list(tx = c("[6] O verall ECG Interpretation ECGRES Categorical select one (nominal) 37 Normal",
"[7] If A bnormal - Clinically Significant, describe ECGA BN Text or A ny V alue 200",
"[8] PR Interval (ms) ECGPRIN Number (continuous) 15",
"[1] Not Done PE2ND Categorical yes/no (dichotomous) 3",
"[2] If Not Done, specify reason: PE2NDR Text or A ny V alue 200",
"[4] Start Date: A ESTDTC Date 11",
"[5] End Date A EENDTC Date 11",
"[6] O ngoing: A EO NGO Categorical yes/no (dichotomous) 3",
"[7] Seriousness Criteria: (check all that apply) A ESA E Categorical select multiple 50",
"[8] Severity: A ECTCA E Categorical select one (nominal) 26 Grade 1 - Mild",
"[2] If Not Done, specify reason: CHMNO Text or A ny V alue 200",
"[6] Laboratory ID (NO TE: If Lab ID is not present, CHMID Categorical select one (nominal) 71 Christus Mother Frances Hospital Laboratory",
"[1] Has subject had any prior surgery related to the PSYN Categorical yes/no (dichotomous) 3",
"[2] Cycle 1 O nly: If less than the expected number of EXBC1 Categorical select one (nominal) 3",
"[3] Cycle EXBCYC Categorical select one (nominal) 8 Cycle 1",
"[4] Dose (mg) EXBDO S Number (continuous) 15",
"[5] Frequency EXBFRQ Categorical select one (nominal) 3 BID",
"[6] Start Date EXBSTDT Date 11",
"[7] Stop Date EXBENDT Date 11",
"[8] Reason for End Date/Stopping EXBREA Categorical select one (nominal) 36 Cycle Completed",
"[9] O ther Reason (specify) EXBREA S Text or A ny V alue 200"
)), row.names = c(NA, -21L), class = c("tbl_df", "tbl", "data.frame"
))
the output I had is:
the yellow part should be in x3 instead. What should I do?

