Get the strings before the comma with R

后端 未结 5 527
清酒与你
清酒与你 2020-12-31 07:16

I am a beginner with R. Now, I have a vector in a data.frame like this

city
Kirkland,
Bethesda,
Wellington,
La Jolla,
Berkeley,
Costa, Evie KW172NJ
Miami,
P         


        
5条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-31 07:57

    This works as well:

    x <- c("London, UK", "Paris, France", "New York, USA")
    
    library(qdap)
    beg2char(x, ",")
    
    ## > beg2char(x, ",")
    ## [1] "London"   "Paris"    "New York"
    

提交回复
热议问题