0
我處理包含字符串如下[R字符串解析挑戰
Col1
------------------------------------------------------------------
Department of Mechanical Engineering, Department of Computer Science
Division of Advanced Machining, Center for Mining and Metallurgy
Department of Aerospace, Center for Science and Delivery
我所試圖做的是包含單詞開始,要麼,部門或Divison或中心,直至逗號(單獨字符串列, )最終輸出應該看起來像這樣
Dept_Mechanical_Eng Dept_Computer_Science Div_Adv_Machining Cntr_Mining_Metallurgy Dept_Aerospace Cntr_Science_Delivery
1 1 0 0 0 0
0 0 1 1 0 0
0 0 1 1 1 1
我在預期的輸出中爲了審美目的而屠殺了實際名稱。任何幫助解析這個字符串非常感謝。
'library(splitstackshape); cSplit_e(mydf,「Col1」,「,」,type =「character」,drop = TRUE,fill = 0)'。也可以從「qdapTools」中查看'strsplit' +'mtabulate'。 – A5C1D2H2I1M1N2O1R2T1