R split on delimiter (split) keep the delimiter (split)

前端 未结 1 1189
清酒与你
清酒与你 2020-11-30 07:28

In R you can use the strsplit function to split a vector on a delimiter(split) as follows:

x <- \"What is this?  It\'s an onion.         


        
相关标签:
1条回答
  • 2020-11-30 08:04

    You can use "(?<=DELIMITERS)":

    unlist(strsplit(x, "(?<=[?.!|])", perl=TRUE))
    
    ## [1] "What is this?"    "  It's an onion." "  What!"          " That's|"        
    ## [5] " Well Crazy.
    
    0 讨论(0)
提交回复
热议问题