[R] How to use escape characters in a string

Bert Gunter gunter.berton at gene.com
Fri Jan 29 23:52:50 CET 2010


Please read R FAQ 7.37.

You need to escape the backslash:
> z<- as.character("`X^`R\\`S")
> z
[1] "`X^`R\\`S"
> cat(z)
`X^`R\`S

Bert Gunter
Genentech Nonclinical Statistics


-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of mary guo
Sent: Friday, January 29, 2010 1:58 PM
To: r-help at r-project.org
Subject: [R] How to use escape characters in a string

Hi,
I want to use a character as below in R,

 as.character("`X^`R\`S")
[1] "`X^`R`S"
Warning messages:
1: '\`' is an unrecognized escape in a character string
2: unrecognized escape removed from "`X^`R\`S"

But I found errors.
Can I use some option in as.character() to change this?

Thanks

Mary

	[[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.



More information about the R-help mailing list