Reputation: 413
Is there a way to replace special character strings in R with gsub?
I have a few columns which have the \\n
in them and I wish to change it to \n
but the gsub doesn't work
Here is an example:
gsub("\\n", "\n", "\\n this is a test \\n data")
I receive the following output:
[1] "\\n this is a test \\n data"
Upvotes: 4
Views: 1004
Reputation: 2126
You can do what you want by adding the argument fixed=T at the end of your gsub commmand.
gsub("\\n", "\n", "\\n this is a test \\n data",fixed=T)
[1] "\n this is a test \n data"
Upvotes: 3