[R] Fwd: string
Peter Dalgaard
P.Dalgaard at biostat.ku.dk
Wed Jan 6 12:33:52 CET 2010
robert-mcfadden at o2.pl wrote:
> I would like to assign a variable y the string: <question><span style="color: #0000FF; font-weight: bold; font-size: 14pt">
> How can I do it - is it possible?
Sure, but you need to escape the double quotes.
The easiest way is actually to read it in, like (sorry about the line
breakage...)
> x <- readLines(n=1)
<question><span style="color: #0000FF; font-weight: bold; font-size: 14pt">
> x
[1] "<question><span style=\"color: #0000FF; font-weight: bold;
font-size: 14pt\">"
but you could also assign directly
> y <- "<question><span style=\"color: #0000FF; font-weight: bold;
font-size: 14pt\">"
> x == y
[1] TRUE
(Notice that the backslashes are not actually part of the string, it is
just that internal quotes are _displayed_ as \", and entered in the same
way. This tends to confuse people at first.)
--
O__ ---- Peter Dalgaard Øster Farimagsgade 5, Entr.B
c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-help
mailing list