Message-ID: <4B447520.6030804@biostat.ku.dk>
Date: 2010-01-06T11:33:52Z
From: Peter Dalgaard
Subject: string
In-Reply-To: <353d4757.3b41c617.4b447293.a3263@o2.pl
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