I m replacing one text in R using sub.
 x<-"My name is ${name}"
 sub("${name}","Tiger",x)
Error Message:
Error in sub("${name}", "Tiger", x) : 
  invalid regular expression '${name}', reason 'Invalid contents of {}'
Input text has {}, How to fix this error?
Use the fixed=TRUE argument:
sub("${name}","Tiger",x, fixed=TRUE)
# [1] "My name is Tiger"
                        $, {, and } need to be escaped:
sub("\\$\\{name\\}","Tiger",x)
# [1] "My name is Tiger"
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With