[R] File path expansion

Martin Maechler maechler at stat.math.ethz.ch
Mon May 28 11:44:28 CEST 2007


>>>>> "Duncan" == Duncan Murdoch <murdoch at stats.uwo.ca>
>>>>>     on Fri, 25 May 2007 15:38:54 -0400 writes:

    Duncan> On 5/25/2007 1:09 PM, Prof Brian Ripley wrote:
    >> On Fri, 25 May 2007, Martin Maechler wrote:
    >> 
    >>>
    >>>> path.expand("~")
    >>> [1] "/home/maechler"
    >>  Yes, but beware that may not do what you want on Windows
    >> in R <= 2.5.0, since someone changed the definition of
    >> 'home' but not path.expand.

    Duncan> A more basic problem is that the definition of "~"
    Duncan> in Windows is very ambiguous.  Is it my Cygwin home
    Duncan> directory, where "cd ~" would take me while in
    Duncan> Cygwin?  

most probably not (see below).  The normal R Windows users
needn't know about Cygwin.

    Duncan> Is it my Windows CSIDL_PERSONAL folder,
    Duncan> usually %HOMEDRIVE%/%HOMEPATH%/My Documents?  Is it
    Duncan> the parent of that folder, %HOMEDRIVE%/%HOMEPATH%?

    Duncan> "~" is a shell concept that makes sense in Unix-like
    Duncan> shells, but not in Windows.

Hmm..
Let's just say "~" is a short cut for 
"The user's home directory".
And yes, that's been a Unix concept for ages, but I think
Windows had adopted that concept, probably with the above 
%HOMEDRIVE%/%HOMEPATH%   

The fact that some of windows software may not "work with"
the user's home directory (but rather a subdirectory of that),
may be a separate issue, but then,  "I'm the windows-non-expert"

Martin Maechler



More information about the R-help mailing list