how to change strings separated by "/" and space to comma separated character vectors

Hi everybody,

the following string is a combined string from a three-by-one data frame.
ADAMTSL3/BGN/DCN/GPC3/SEMA5A GPC1/GPC4/SDC4/THBS1 ADAMTS4/ADAMTS6/ADAMTSL1/CFP/FMOD

I want to change it as below:
'ADAMTSL3', 'BGN', 'DCN', 'GPC3', 'SEMA5A', 'GPC1', 'GPC4', 'SDC4', 'THBS1', 'ADAMTS4', 'ADAMTS6' ,'ADAMTSL1' ,'CFP, FMOD'

would you please forward some advice !!
Thank you for your help.
Best,
Amare

assuming your dataset is like this:

x <- data.frame(
a="ADAMTSL3/BGN/DCN/GPC3/SEMA5A",
b="GPC1/GPC4/SDC4/THBS1",
c="ADAMTS4/ADAMTS6/ADAMTSL1/CFP/FMOD"
)
x

looks like you want this:

x <- as.vector(unlist(sapply(x, strsplit, '/')))
x

or maybe you want to see this:

dput(x)

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.