You have to escape it twice, first for R, second for the regex.
Up vote 5 down vote favorite share g+ share fb share tw.
I've been using gsub("toreplace","replacement", myvector) to clean out data in R. While this works for commas and the like, removing "$" has no effect. So if I do gsub("$","",myvector) all the dollar signs remain in place.
I think this is because $ is a special character in R. I tried escaping it "\$" but that yields the same result (no effect). And I couldn't find a resource on escaping special characters in R.
Obviously I should do this in preprocessing. But I was wondering if anyone out there knew how to either a) escape special characters in R b) get rid of pesky $ in R directly. For science.
R escaping link|improve this question edited Jul 10 '11 at 7:21gvLearner46110 asked Jul 10 '11 at 6:52araneae836 25% accept rate.
You have to escape it twice, first for R, second for the regex. Gsub('\\$', '', c("a$a", "bb$")) 1 "aa" "bb" See? Quotes for details on quoting and escaping.
Escaping characters can be a pain some times, but just putting it in square brackets (make it a character class) helps with this: > gsub("$","",c("$100","ta$ty")) 1 "100" "taty.
Use fixed = TRUE: gsub('$', '', c("a$a", "bb$"), fixed = TRUE) Then you don't need to worry about any special characters. In stringr, this is implemented a little differently: library(stringr) str_replace_all(c("$100","ta$ty"), fixed("$"), "") Thanks to DiggyF and James for the examples!
Gsub more carefully. Thanks! – araneae Jul 10 '11 at 18:00.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.