[R] Quotes inside char string

David Winsemius dwinsemius at comcast.net
Tue Dec 20 20:47:51 CET 2011


On Dec 20, 2011, at 2:31 PM, Mike Pfeiff wrote:

> Thank you Uwe.  I can't get my sqlQuery to work and thought that it  
> must be the "\" embedded in the text string, I guess not if R  
> doesn't pass the "\".  Thanks for your response.

But it did pass the '"'. How does that software deal with an  
expression like:

Test Score="A

I'm guessing that your failure to close the quotes is part of the  
problem ( as well as your use of cat() ).

>
> -----Original Message-----
> From: Uwe Ligges [mailto:ligges at statistik.tu-dortmund.de]
> Sent: Tuesday, December 20, 2011 1:20 PM
> To: Mike Pfeiff
> Cc: 'R-help at r-project.org'
> Subject: Re: [R] Quotes inside char string
>
>
>
> On 20.12.2011 20:10, Mike Pfeiff wrote:
>> How do I return a character string with quotes inside string?
>>
>> For example, what logic do I use if I want to return the following:
>>
>> Test Score="A"
>>
>> I tried the following  ....
>>
>>                Score<-paste("Test Score=","A",sep='"')
>>
>> But it returned a "\" inside:
>>
>>
>>                "Test Score=\"A"
>>
>>
>>
>> Any assistance would be greatly appreciated.
>
> That is the print()ed R representation of it. The underlying value
> *within* the quoted string is actually:
>  Test Score="A
> and that is always true. E.g. in your example with the SQL query  
> this question probably is derived from.
> cat() shows the actual version (but does not return) it.
>
> Uwe Ligges
>
>
>
>
>>
>> 	[[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-help at 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 at 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.

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list