Message-ID: <Pine.A41.4.44.0212220301220.49202-100000@mead4.u.washington.edu>
Date: 2002-12-22T12:08:03Z
From: John Miyamoto
Subject: pasting "\" into character strings
In-Reply-To: <Pine.LNX.4.31.0212220820010.26654-100000@gannet.stats>
On Sun, 22 Dec 2002 ripley at stats.ox.ac.uk wrote:
> Why guess? It's in the R Language definition and in all good books on
> S/R.
>
> `String constants are delimited by a pair of single (') or double (")
> quotes and can contain all other printable characters. Quotes and other
> special characters within strings are specified using escape sequences:'
>
> paste("c:", "work", "part1.txt", sep="\\")
Reply: The problem with this command is that it produces
paste("c:", "work", "part1.txt", sep="\\")
[1] "c:\\work\\part1.txt"
whereas I want "c:\work\part1.txt". Some people have suggested to try
'file.path', but it either doesn't work, or I don't know how to make it
work.
> file.path("c:","work","part1.txt", fsep = "\")
Error: syntax error
> file.path("c:","work","part1.txt", fsep = "\\")
[1] "c:\\work\\part1.txt"
John Miyamoto