0

How can I use the paste function in R to print double quote (") without an escape character appearing in front.

> paste('"')
[1] "\""
> paste('\"')
[1] "\""
> paste('\\"')
[1] "\\\""
> paste('\\\"')
[1] "\\\""
> z=paste('"')
> z
[1] "\""
> gsub('\\','',z) #to remove the backslashes
Error in gsub("\\", "", z) : 
  invalid regular expression '\', reason 'Trailing backslash'

I want

z="

only.

It is for a quick format of a long file I am looping through

paste0('ELSEIF [Age 1]="Qs103Ew00',i,'" then [Qs103Ew00',i,']')

Is this possible?

frank
  • 3,036
  • 7
  • 33
  • 65

0 Answers0