user2300940
user2300940

Reputation: 2385

convert string with substrings into multiple strings

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"

Upvotes: 0

Views: 43

Answers (1)

asd-tm
asd-tm

Reputation: 5253

Use str_split() function from stringr package:

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

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

Upvotes: 2

Related Questions