[R] FW: impossible escape?

From: Charles Annis, P.E. <Charles.Annis_at_statisticalengineering.com>
Date: Wed 11 Oct 2006 - 17:53:23 GMT


D'oh!

I've been using cat() but somehow never got the bigger picture.

Thanks!!!

Charles Annis, P.E.

Charles.Annis@StatisticalEngineering.com phone: 561-352-9699
eFax: 614-455-3265
http://www.StatisticalEngineering.com  

-----Original Message-----
From: Marc Schwartz [mailto:MSchwartz@mn.rr.com] Sent: Wednesday, October 11, 2006 1:45 PM To: Charles.Annis@statisticalengineering.com Cc: r-help@stat.math.ethz.ch
Subject: Re: [R] impossible escape?

On Wed, 2006-10-11 at 13:30 -0400, Charles Annis, P.E. wrote:
> Greetings:
>
> I've searched the R archives with no luck.
>
> I want to print this to the screen as part of on-screen instructions as an
> example:
>
> default.FACTOR.labels <- c("Probe1", "Probe2", "Probe3")
>
> I can't seem to trick gsub()
>
> gsub("'", "\"", "default.FACTOR.labels <- c('Probe1', 'Probe2',
'Probe3'))")
>
> [1] "default.FACTOR.labels <- c(\"Probe1\", \"Probe2\", \"Probe3\"))"
> ^ ^ ^ ^ ^ ^

>
> which gives me \" rather than "
>
> Is it possible to escape the " character?
>
> Thanks.
>
> Charles Annis, P.E.

You don't need the gsub() and you want to use cat() to output the text:

> cat("default.FACTOR.labels <- c(\"Probe1\", \"Probe2\", \"Probe3

       \")\n")
default.FACTOR.labels <- c("Probe1", "Probe2", "Probe3")

cat() will properly interpret and output the escaped characters. The newline character "\n" will return the cursor to the next line, so that the R prompt is not at the end of the last line output.

HTH, Marc Schwartz



R-help@stat.math.ethz.ch 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. Received on Thu Oct 12 03:58:57 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 11 Oct 2006 - 18:30:09 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.