[R] how to insert a double quote with the paste function?

Patrick Burns pburns at pburns.seanet.com
Thu Sep 11 10:24:53 CEST 2003

The paste is doing the right thing -- it is how it is displayed
that matters:

 > jj <- paste("hello", "\"world\"")
 > jj
[1] "hello \"world\""
 > cat(jj)
hello "world"> print(jj, quote=FALSE)
[1] hello "world"

Patrick Burns

Burns Statistics
patrick at burns-stat.com
+44 (0)20 8525 0696
(home of S Poetry and "A Guide for the Unwilling S User")

Philippe Hupé wrote:

> Hello,
> I would like to write in a variable the following string :
> Hello "World"
> If I do cat("Hello ","\"World\""), I have the good result on the 
> screen but it can not be affected to a variable. If I do the same 
> thing with paste paste("Hello ","\"World\"") it does not work since \" 
> seems to be not recognized. So what is the trick to do that.
> Thanks,
> Philippe

More information about the R-help mailing list