Eddie Eddie - 3 months ago 17
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.

library(stringr)

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


my data set is

#dts
id Campaign
1 C|D|E


and I wish the following output:

id Campaign
1 CDE

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