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, ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance Kliniekstraat 25 1070 Anderlecht Belgium To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey [[alternative HTML version deleted]]
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]]
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]]
On 11/08/2015 10:51 AM, Sarah Goslee 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?)The tilde meaning "home" is not a concept in Windows, but R fakes it. This is described in ?path.expand and the R for Windows FAQ. Thierry should set the R_USER environment variable to whatever home dir he wants. RStudio is probably doing that for him. Duncan Murdoch> > 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, >>
In the R GUI the output is > path.expand("~") [1] "~" Did you set the environment variable R_USER to something odd like "~"? Bill Dunlap TIBCO Software wdunlap tibco.com On Tue, Aug 11, 2015 at 7: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, > > ir. Thierry Onkelinx > Instituut voor natuur- en bosonderzoek / Research Institute for Nature and > Forest > team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance > Kliniekstraat 25 > 1070 Anderlecht > Belgium > > To call in the statistician after the experiment is done may be no more > than asking him to perform a post-mortem examination: he may be able to say > what the experiment died of. ~ Sir Ronald Aylmer Fisher > The plural of anecdote is not data. ~ Roger Brinner > The combination of some data and an aching desire for an answer does not > ensure that a reasonable answer can be extracted from a given body of data. > ~ John Tukey > > [[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. >[[alternative HTML version deleted]]
Dear Bill, The culprit was the environment variable HOME which was set to "~". Changing it to "C:/Users/thierry_onkelinx/Documents" solved the problem. Thanks for the hint. Best regards, ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance Kliniekstraat 25 1070 Anderlecht Belgium To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey 2015-08-11 17:39 GMT+02:00 William Dunlap <wdunlap at tibco.com>:> In the R GUI the output is > > path.expand("~") > [1] "~" > > Did you set the environment variable R_USER to something odd like "~"? > > Bill Dunlap > TIBCO Software > wdunlap tibco.com > > On Tue, Aug 11, 2015 at 7: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, >> >> ir. Thierry Onkelinx >> Instituut voor natuur- en bosonderzoek / Research Institute for Nature and >> Forest >> team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance >> Kliniekstraat 25 >> 1070 Anderlecht >> Belgium >> >> To call in the statistician after the experiment is done may be no more >> than asking him to perform a post-mortem examination: he may be able to >> say >> what the experiment died of. ~ Sir Ronald Aylmer Fisher >> The plural of anecdote is not data. ~ Roger Brinner >> The combination of some data and an aching desire for an answer does not >> ensure that a reasonable answer can be extracted from a given body of >> data. >> ~ John Tukey >> >> [[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. >> > >[[alternative HTML version deleted]]