Tom La Bone wrote:
I know this is easy, but I am stumped:
gsub("0","K","8.00+00")
[1] "8.KK+KK"
gsub("+","K","8.00+00")
Error in gsub("+", "K", "8.00+00") : invalid regular expression '+'
In addition: Warning message:
In gsub("+", "K", "8.00+00") :
regcomp error: 'Invalid preceding regular expression'
I don't understand the error message. How do I go about replacing the "+" in
the string "8.00+00" with another character?
+ has a special meaning in regular expressions
gsub( "[+]", "K", "8.00+00" )
gsub( "\\+", "K", "8.00+00" )
gsub( "+", "K", "8.00+00", fixed = TRUE )
see ?regex for details
Tom
--
Romain Francois
Independent R Consultant
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.