Eddie Eddie - 11 months ago 64
R Question

Library (stringr) doesn't work for "|"

I use stringer package to replace some of the characters. It is perfectly fine for all the characters but surprisingly doesn't work for |. I wish to remove |. But it doesn't work.


dts$new <- str_replace_all(dts$Campaign, "|", "")

my data set is

id Campaign
1 C|D|E

and I wish the following output:

id Campaign

Answer Source
 str_replace_all(dts$Campaign, "[|]", "")