Message-ID: <Pine.GSO.4.33_heb2.09.0504191913170.1355-100000@csd.cs.technion.ac.il>
Date: 2005-04-19T16:14:05Z
From: Firas Swidan
Subject: Printing a single "\" character
In-Reply-To: <Pine.A41.4.61b.0504190904560.309968@homer05.u.washington.edu>
Hi Thomas,
thanks for the help, it does work.
Regards,
Firas.
On Tue, 19 Apr 2005, Thomas Lumley wrote:
> On Tue, 19 Apr 2005, Firas Swidan wrote:
>
> > Hi,
> > I have a small R question: how to print a single "\" character? I have the
> > following results:
> >> print("\") does not work
> >
> >> print("\\")
> > [1] "\\"
>
> Use cat("\\").
>
> > I need to make the following substitution as well, but it does not work
> > either:
> >> sub("_","\_","g_g")
> > [1] "g_g"
>
> Use
> sub("_","\\\\_","g_g")
>
> If you print() the result it will look as though it has a double \, but
> that's an optical illusion. cat() will show it correctly with a single \
> (and nchar() will confirm that it has 4 characters).
>
> -thomas
>