Home > Enterprise >  convert string with substrings into multiple strings
convert string with substrings into multiple strings

Time:10-31

I want ot convert my slash-separated strings into separate strings with quotes. Now, by strings is a long string where the substrings are separated by slash.

in

[1] "RPS3A/RPL9/RPS25"

out

[1] "RPS3A" "RPL9"  "RPS25"

CodePudding user response:

Use str_split() function from stringr package:

library(stringr)
str_split("RPS3A/RPL9/RPS25", "/")

unlist() the prior output afterwards if type cast required.

  • Related