[R] Problem with path.expand("~")

John McKown john.archie.mckown at gmail.com
Tue Aug 11 17:01:07 CEST 2015


Works correctly on 3.1.1 under Windows . You may have found a problem in
the Windows port. The Linux version of R 3.2.1 works correctly, for me.

R version 3.1.1 (2014-07-10) -- "Sock it to Me"
Copyright (C) 2014 The R Foundation for Statistical Computing
Platform: i386-w64-mingw32/i386 (32-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

[Previously saved workspace restored]

> path.expand("~")
[1] "C:\\Users\\john.mckown\\Documents"
>

===

R version 3.1.1 (2014-07-10) -- "Sock it to Me"
Copyright (C) 2014 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

[Previously saved workspace restored]

> path.expand("~")
[1] "C:\\Users\\john.mckown\\Documents"
>


On Tue, Aug 11, 2015 at 9:51 AM, Sarah Goslee <sarah.goslee at gmail.com>
wrote:

> Hm.
>
> On my linux system:
>
> > path.expand("~")
> [1] "/home/sarahg"
>
> The help file says:
>      Expand a path name, for example by replacing a leading tilde by
>      the user's home directory (if defined on that platform).
>
> Does Windows 7 define ~?
>
> Just because RStudio defines it for you, doesn't mean that R shares that
> same setup; if R is checking with the operating system, then it depends on
> the Windows setup. You could, I assume, define ~ in Windows yourself, or
> write your own path.expand() to do so. I have no idea which option the
> RStudio designers took.
>
> Could you use getwd() to get the output you're looking for? I would expect
> ~ to properly be "C:/Users/thierry_onkelinx" and getwd() to be what you've
> set Start in as, suggesting that not only did RStudio define ~ for Windows,
> they did it in a non-standard way. (Unless your home directory on Windows
> should be Documents?)
>
> Sarah
>
> On Tue, Aug 11, 2015 at 10:41 AM, Thierry Onkelinx <
> thierry.onkelinx at inbo.be
> > wrote:
>
> > Dear all,
> >
> > I'm puzzled by the behaviour of path.expand("~")
> >
> > In the RStudio IDE the output is
> > > path.expand("~")
> > [1] "C:/Users/thierry_onkelinx/Documents"
> >
> > In the R GUI the output is
> > > path.expand("~")
> > [1] "~"
> >
> > But I'm expecting the same result as in the RStudio IDE. The "Start in"
> > parameter of shortcut to the R GUI has the value
> > "C:\Users\thierry_onkelinx\Documents"
> >
> > The problem is that I use normalizePath("~/analysis"). This
> > yield "C:\\Users\\thierry_onkelinx\\Documents\\analysis" in RStudio
> >
> > It throws an error in the R GUI
> > "C:\\Users\\thierry_onkelinx\\Documents\\~\\analysis"
> > Warning message:
> > In normalizePath(path.expand(path), winslash, mustWork) :
> >   path[1]="~/analysis": Het systeem kan het opgegeven pad niet vinden
> >
> > # sessionInfo() in RStudio
> > R version 3.2.1 (2015-06-18)
> > Platform: x86_64-w64-mingw32/x64 (64-bit)
> > Running under: Windows 7 x64 (build 7601) Service Pack 1
> >
> > locale:
> > [1] LC_COLLATE=Dutch_Belgium.1252  LC_CTYPE=Dutch_Belgium.1252
> >  LC_MONETARY=Dutch_Belgium.1252
> > [4] LC_NUMERIC=C                   LC_TIME=Dutch_Belgium.1252
> >
> > attached base packages:
> > [1] stats     graphics  grDevices utils     datasets  methods   base
> >
> > loaded via a namespace (and not attached):
> > [1] tools_3.2.1    fortunes_1.5-2
> >
> > # sessionInfo() from R GUI
> > R version 3.2.1 (2015-06-18)
> > Platform: x86_64-w64-mingw32/x64 (64-bit)
> > Running under: Windows 7 x64 (build 7601) Service Pack 1
> >
> > locale:
> > [1] LC_COLLATE=Dutch_Belgium.1252  LC_CTYPE=Dutch_Belgium.1252
> > [3] LC_MONETARY=Dutch_Belgium.1252 LC_NUMERIC=C
> > [5] LC_TIME=Dutch_Belgium.1252
> >
> > attached base packages:
> > [1] stats     graphics  grDevices utils     datasets  methods   base
> >
> > loaded via a namespace (and not attached):
> > [1] tools_3.2.1    fortunes_1.5-2
> >
> >
> > Best regards,
> >
> --
> Sarah Goslee
> http://www.functionaldiversity.org
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 

Schrodinger's backup: The condition of any backup is unknown until a
restore is attempted.

Yoda of Borg, we are. Futile, resistance is, yes. Assimilated, you will be.

He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! <><
John McKown

	[[alternative HTML version deleted]]



More information about the R-help mailing list