Paul -
When you print a string, it escapes the quotes with a backslash. That's a property of the print() function,
not the string itself.
   If you want to see the string, use cat().  The nchar()
function is also useful:

str1 <- '"xyz"'
qr2 <- paste('abc',str1,sep='')
print(qr2)
[1] "abc\"xyz\""
cat(qr2,'\n')
abc"xyz"
nchar(qr2)
[1] 8

                                        - Phil Spector
                                         Statistical Computing Facility
                                         Department of Statistics
                                         UC Berkeley
                                         spec...@stat.berkeley.edu


On Wed, 30 Jun 2010, Paul Evans wrote:

Hi,

How can I get double quotes embedded in the string?

Example:

--------------
str1 <- '"xyz"'

## desired output
# abc"xyz"

qr2 <- paste('abc',str1,sep='')
print(qr2)

-----------------

Actual output:

[1] "abc\"str\""

I also tried putting an escape sequence before the quote, but couldn't get the
string that I want.


thanks,



        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to