pego.enrico at tiscali.it
2008-Oct-03 08:05 UTC
[Rd] A strange behaviour of file.path in Windows? (PR#13119)
Full_Name: Enrico Pegoraro Version: 2.7.2 OS: Windows (Vista or Xp PRO) Italian Submission from: (NULL) (87.4.189.202) If you send these lines of code: outdir="c:/pippo" file.path(outdir,"pluto.html") R replies correctly: [1] "c:/pippo/pluto.html" But if you change the first steps to: outdir="" file.path(outdir,"pluto.html") R replies (uncorrectly, I think) [1] "/c:/pippo/pluto.html" This problem influence the R2HTML package too, which, if you send a line as: targetHtml=HTMLInitFile(outdir="",filename="htmlFile",Title ="Title") in windows it submit an error because of file.path() error. Thank you Enrico
Richard.Cotton at hsl.gov.uk
2008-Oct-03 10:27 UTC
[Rd] A strange behaviour of file.path in Windows? (PR#13119)
> If you send these lines of code: > > outdir="c:/pippo" > file.path(outdir,"pluto.html") > > R replies correctly: > > [1] "c:/pippo/pluto.html" > > But if you change the first steps to: > > outdir="" > file.path(outdir,"pluto.html") > > R replies (uncorrectly, I think) > > [1] "/c:/pippo/pluto.html"I don't get the same output as you. Are you sure you haven't changed output somewhere else in your code? outdir="c:/pippo" file.path(outdir,"pluto.html") [1] "c:/pippo/pluto.html" outdir="" file.path(outdir,"pluto.html") [1] "/pluto.html" This is under R2.7.2/ Win XP. Regards, Richie. Mathematical Sciences Unit HSL ------------------------------------------------------------------------ ATTENTION: This message contains privileged and confidential inform...{{dropped:20}}
Prof Brian Ripley
2008-Oct-03 11:02 UTC
[Rd] A strange behaviour of file.path in Windows? (PR#13119)
On Fri, 3 Oct 2008, pego.enrico at tiscali.it wrote:> Full_Name: Enrico Pegoraro > Version: 2.7.2 > OS: Windows (Vista or Xp PRO) Italian > Submission from: (NULL) (87.4.189.202) > > > If you send these lines of code: > > outdir="c:/pippo" > file.path(outdir,"pluto.html") > > R replies correctly: > > [1] "c:/pippo/pluto.html" > > But if you change the first steps to: > > outdir="" > file.path(outdir,"pluto.html") > > R replies (uncorrectly, I think)> [1] "/c:/pippo/pluto.html"Not for me! I get> outdir="" > file.path(outdir,"pluto.html")[1] "/pluto.html" which is as documented, hence correct. Furthermore, the code cannot possibly give your answer unless 'c:/pippo' has some special status on your system, and you haven't told us anything about that. If you do file.path("", "c:/pippo", "pluto.html") you get what you indicate, but that is user error (an empty server/share specification).> > This problem influence the R2HTML package too, which, if you send a line as: > > targetHtml=HTMLInitFile(outdir="",filename="htmlFile",Title ="Title") > > in windows it submit an error because of file.path() error.It will affect any such misuse of file.path, of course. It really is not a good idea to use empty file path elements, especially on Windows[*]. If you mean the current directory, use ".". [*] On Unix // is equivalent to /. On Windows \\ or // may have a special meaning (a share) or be regarded as invalid. A trailing / or \ can be disastrous.> Thank you > Enrico-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595