Avoid R function paste generating backslash for quotes

Viewed 8081

I am trying to get two strings that contain quotations ("") combined as a character/string vector or with R function paste so I can plug the result in the argument x of writeFormula in openxlsx package.

An example is like this

paste('HYPERLINK("file)',':///"&path!$C$1&TRIM(MID(CELL("filename",B',sep="")

and I hope that it should produce the result like this

HYPERLINK("file:///"&path!$C$1&TRIM(MID(CELL("filename",B

but it actually produces the result with a backslash in front of the ":

[1] "HYPERLINK(\"file):///\"&path!$C$1&TRIM(MID(CELL(\"filename\",B"

I have searched for many potential solutions like replace paste with cat or add noquote function in front of paste but the output is not a character vector. Functions like toString or as.character could convert these results to strings but the backslash comes back as well.

Really appreciate any helps with this. Thanks.

1 Answers
Related