Reputation:
i just want to remove '$' into text and i am using stringr to do this
a<-'r$studio'
require(stringr)
str_replace(string=a,pattern='$',replacement='')
It gives me following output
[1] 'r$studio'
rstudio
i also tried it using paste function which is also not providing me what i want
paste(a,sep='$')
[1] 'r$studio'
please provide me some help on this .
Upvotes: 1
Views: 70
Reputation: 4444
If you really want a stringr
solution:
str_replace(a, "[$]", "")
# [1] "rstudio"
Upvotes: 2
Reputation: 887961
We can use sub
. The $
is a special character and it means the end of the string. So, we should either escape it (\\$
) or place it inside square brackets to read it as the literal character in the pattern argument and replace it by ''
.
sub('[$]', '', a)
#[1] "rstudio"
Upvotes: 4