How do you replace a "backslash" by nothing in a string ?
I'm doing this :
A = "plot_maker(df,c(\"var1\", \"var2\"))"
gsub("\\\\","11", A)
it's not working
I would like to have something like this at the end :
plot_maker(df,c("var1", "var2"))
How do you replace a "backslash" by nothing in a string ?
I'm doing this :
A = "plot_maker(df,c(\"var1\", \"var2\"))"
gsub("\\\\","11", A)
it's not working
I would like to have something like this at the end :
plot_maker(df,c("var1", "var2"))
You're confused by the distinction between a string and the way it is displayed by R. Your string doesn't actually have any backslashes in it, but R is adding them when it displays. You can see this with
print(A, quote = FALSE)
## [1] plot_maker(df,c("var1", "var2"))
or
cat(A, "\n")
## plot_maker(df,c("var1", "var2"))
(the \n
is added to print a newline after the string)