我與R.初學者現在,我有一個data.frame矢量這樣獲取逗號之前的字符串爲R
city
Kirkland,
Bethesda,
Wellington,
La Jolla,
Berkeley,
Costa, Evie KW172NJ
Miami,
Plano,
Sacramento,
Middletown,
Webster,
Houston,
Denver,
Kirkland,
Pinecrest,
Tarzana,
Boulder,
Westfield,
Fair Haven,
Royal Palm Beach, Fl
Westport,
Encino,
Oak Ridge,
我想清洗它。我想要的是逗號前的所有城市名稱。我怎樣才能在R中得到結果?謝謝!
+1我正要建議幾乎完全一樣......'GSUB(「^(+) ,。*「,」\\ 1「,df $ city)' –