escaping - How do I strip dollar signs ($) from data/ escape special characters in R? -



escaping - How do I strip dollar signs ($) from data/ escape special characters in R? -

i've been using gsub("toreplace","replacement", myvector) clean out info in r. while works commas , like, removing "$" has no effect. if gsub("$","",myvector) dollar signs remain in place.

i think because $ special character in r. tried escaping "\$" yields same result (no effect). , couldn't find resource on escaping special characters in r.

obviously should in preprocessing. wondering if out there knew how either a) escape special characters in r b) rid of pesky $ in r directly. science.

you have escape twice, first r, sec regex.

gsub('\\$', '', c("a$a", "bb$")) [1] "aa" "bb"

see ?quotes details on quoting , escaping.

r escaping

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -