Can't there be a cd command?

classic Classic list List threaded Threaded
35 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Can't there be a cd command?

Issac Trotts
R is quite a powerful environment.  Here's a small way it could be even better.

I wanted to change the working directory, so I tried the obvious thing

> cd("foo")
Error: couldn't find function "cd"

Then I looked for `directory' in the FAQ but found nothing.  A search
for directory in the introduction also turned up nothing.

A Google search for "gnu R change directory" brought up a link to the
Windows FAQ, and there was the answer: setwd.  Oddly enough, setwd is
not mentioned in the general FAQ, the introduction, or the language
definition.

Hopefully someone can add a mention of setwd to the general FAQ or the
intro.  Even better would be to have a cd() command, since that's what
almost every beginner will try first.

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: Can't there be a cd command?

Bert Gunter
You do not say, but if you are on Windows see the R for Windows FAQ 2.14
where getwd() is explicitly mentioned. setwd() is on the same man page.

Also the R for Windows File menu has a "Change dir ..." entry. So I think R
core has already taken care of this, at least on Windows.

-- Bert Gunter
Genentech Non-Clinical Statistics
South San Francisco, CA
 
"The business of the statistician is to catalyze the scientific learning
process."  - George E. P. Box
 
 

> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of Issac Trotts
> Sent: Tuesday, May 09, 2006 2:51 PM
> To: [hidden email]
> Subject: [R] Can't there be a cd command?
>
> R is quite a powerful environment.  Here's a small way it
> could be even better.
>
> I wanted to change the working directory, so I tried the obvious thing
>
> > cd("foo")
> Error: couldn't find function "cd"
>
> Then I looked for `directory' in the FAQ but found nothing.  A search
> for directory in the introduction also turned up nothing.
>
> A Google search for "gnu R change directory" brought up a link to the
> Windows FAQ, and there was the answer: setwd.  Oddly enough, setwd is
> not mentioned in the general FAQ, the introduction, or the language
> definition.
>
> Hopefully someone can add a mention of setwd to the general FAQ or the
> intro.  Even better would be to have a cd() command, since that's what
> almost every beginner will try first.
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: Can't there be a cd command?

Issac Trotts
I'm on Linux, so it didn't occur to me to look in the Windows FAQ
until it came up in the Google search.  Why should Windows users be
the only ones who learn how to change directories?

Issac

On 5/9/06, Berton Gunter <[hidden email]> wrote:

> You do not say, but if you are on Windows see the R for Windows FAQ 2.14
> where getwd() is explicitly mentioned. setwd() is on the same man page.
>
> Also the R for Windows File menu has a "Change dir ..." entry. So I think R
> core has already taken care of this, at least on Windows.
>
> -- Bert Gunter
> Genentech Non-Clinical Statistics
> South San Francisco, CA
>
> "The business of the statistician is to catalyze the scientific learning
> process."  - George E. P. Box
>
>
>
> > -----Original Message-----
> > From: [hidden email]
> > [mailto:[hidden email]] On Behalf Of Issac Trotts
> > Sent: Tuesday, May 09, 2006 2:51 PM
> > To: [hidden email]
> > Subject: [R] Can't there be a cd command?
> >
> > R is quite a powerful environment.  Here's a small way it
> > could be even better.
> >
> > I wanted to change the working directory, so I tried the obvious thing
> >
> > > cd("foo")
> > Error: couldn't find function "cd"
> >
> > Then I looked for `directory' in the FAQ but found nothing.  A search
> > for directory in the introduction also turned up nothing.
> >
> > A Google search for "gnu R change directory" brought up a link to the
> > Windows FAQ, and there was the answer: setwd.  Oddly enough, setwd is
> > not mentioned in the general FAQ, the introduction, or the language
> > definition.
> >
> > Hopefully someone can add a mention of setwd to the general FAQ or the
> > intro.  Even better would be to have a cd() command, since that's what
> > almost every beginner will try first.
> >
> > ______________________________________________
> > [hidden email] mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide!
> > http://www.R-project.org/posting-guide.html
> >
>
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: Can't there be a cd command?

Steve Buyske
I believe Berton Gunter was trying to be helpful, as you didn't
mention your operating system, rather than suggesting that Linux
users read the Windows FAQ.

However, when I type (under OS X)

     help.search("directory")

the 6th line returned is

     getwd(base)             Get or Set Working Directory

which seems clear enough.

Steve Buyske




At 3:11 PM -0700 5/9/06, Issac Trotts wrote:

>I'm on Linux, so it didn't occur to me to look in the Windows FAQ
>until it came up in the Google search.  Why should Windows users be
>the only ones who learn how to change directories?
>
>Issac
>
>On 5/9/06, Berton Gunter <[hidden email]> wrote:
>>  You do not say, but if you are on Windows see the R for Windows FAQ 2.14
>>  where getwd() is explicitly mentioned. setwd() is on the same man page.
>>
>>  Also the R for Windows File menu has a "Change dir ..." entry. So I think R
>>  core has already taken care of this, at least on Windows.
>>
>>  -- Bert Gunter
>>  Genentech Non-Clinical Statistics
>>  South San Francisco, CA
>>
>>  "The business of the statistician is to catalyze the scientific learning
>>  process."  - George E. P. Box
>>
>>
>>
>>  > -----Original Message-----
>>  > From: [hidden email]
>>  > [mailto:[hidden email]] On Behalf Of Issac Trotts
>>  > Sent: Tuesday, May 09, 2006 2:51 PM
>>  > To: [hidden email]
>>  > Subject: [R] Can't there be a cd command?
>>  >
>>  > R is quite a powerful environment.  Here's a small way it
>>  > could be even better.
>>  >
>>  > I wanted to change the working directory, so I tried the obvious thing
>>  >
>>  > > cd("foo")
>>  > Error: couldn't find function "cd"
>>  >
>>  > Then I looked for `directory' in the FAQ but found nothing.  A search
>>  > for directory in the introduction also turned up nothing.
>>  >
>>  > A Google search for "gnu R change directory" brought up a link to the
>>  > Windows FAQ, and there was the answer: setwd.  Oddly enough, setwd is
>>  > not mentioned in the general FAQ, the introduction, or the language
>>  > definition.
>>  >
>>  > Hopefully someone can add a mention of setwd to the general FAQ or the
>>  > intro.  Even better would be to have a cd() command, since that's what
>>  > almost every beginner will try first.
>>  >
>>  > ______________________________________________
>>  > [hidden email] mailing list
>>  > https://stat.ethz.ch/mailman/listinfo/r-help
>>  > PLEASE do read the posting guide!
>>  > http://www.R-project.org/posting-guide.html
>>  >
>>
>>
>
>______________________________________________
>[hidden email] mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: Can't there be a cd command?

Peter Dalgaard
In reply to this post by Issac Trotts
"Issac Trotts" <[hidden email]> writes:

> I'm on Linux, so it didn't occur to me to look in the Windows FAQ
> until it came up in the Google search.  Why should Windows users be
> the only ones who learn how to change directories?

Well, on Linux et al., the normal mode of operation is to start R from
the commmand line in the directory where you want to be. On Windows
you start from a desktop icon or a menu entry, which implies that
you're always in the same directory, and usually the wrong one.

--
   O__  ---- Peter Dalgaard             Ă˜ster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - ([hidden email])                  FAX: (+45) 35327907

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: Can't there be a cd command?

Prof Brian Ripley
On Wed, 10 May 2006, Peter Dalgaard wrote:

> "Issac Trotts" <[hidden email]> writes:
>
>> I'm on Linux, so it didn't occur to me to look in the Windows FAQ
>> until it came up in the Google search.  Why should Windows users be
>> the only ones who learn how to change directories?
>
> Well, on Linux et al., the normal mode of operation is to start R from
> the commmand line in the directory where you want to be. On Windows
> you start from a desktop icon or a menu entry, which implies that
> you're always in the same directory, and usually the wrong one.

Exactly.  I don't think I have ever used setwd() on Linux.

Also, I have never seen this asked before for a Unix-alike, so it seems
not to be a >F<AQ.  There is a common tendency for users who run into a
problem to think everyone does too, and it isn't necessarily so.
Frequently asked questions do make it to the FAQs: it is a defence
mechanism for the volunteers supporting R.

help.search("directory")  gets you there.

--
Brian D. Ripley,                  [hidden email]
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

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: Can't there be a cd command?

Issac Trotts
On 5/9/06, Prof Brian Ripley <[hidden email]> wrote:

> On Wed, 10 May 2006, Peter Dalgaard wrote:
>
> > "Issac Trotts" <[hidden email]> writes:
> >
> >> I'm on Linux, so it didn't occur to me to look in the Windows FAQ
> >> until it came up in the Google search.  Why should Windows users be
> >> the only ones who learn how to change directories?
> >
> > Well, on Linux et al., the normal mode of operation is to start R from
> > the commmand line in the directory where you want to be. On Windows
> > you start from a desktop icon or a menu entry, which implies that
> > you're always in the same directory, and usually the wrong one.
>
> Exactly.  I don't think I have ever used setwd() on Linux.
>
> Also, I have never seen this asked before for a Unix-alike, so it seems
> not to be a >F<AQ.  There is a common tendency for users who run into a
> problem to think everyone does too, and it isn't necessarily so.
>
> Frequently asked questions do make it to the FAQs: it is a defence
> mechanism for the volunteers supporting R.
>
> help.search("directory")  gets you there.

OK, good to know.  Thanks for helping.

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: Can't there be a cd command?

joerg van den hoff
Issac Trotts wrote:

> On 5/9/06, Prof Brian Ripley <[hidden email]> wrote:
>> On Wed, 10 May 2006, Peter Dalgaard wrote:
>>
>>> "Issac Trotts" <[hidden email]> writes:
>>>
>>>> I'm on Linux, so it didn't occur to me to look in the Windows FAQ
>>>> until it came up in the Google search.  Why should Windows users be
>>>> the only ones who learn how to change directories?
>>> Well, on Linux et al., the normal mode of operation is to start R from
>>> the commmand line in the directory where you want to be. On Windows
>>> you start from a desktop icon or a menu entry, which implies that
>>> you're always in the same directory, and usually the wrong one.
>> Exactly.  I don't think I have ever used setwd() on Linux.
>>
>> Also, I have never seen this asked before for a Unix-alike, so it seems
>> not to be a >F<AQ.  There is a common tendency for users who run into a
>> problem to think everyone does too, and it isn't necessarily so.
>>
>> Frequently asked questions do make it to the FAQs: it is a defence
>> mechanism for the volunteers supporting R.
>>
>> help.search("directory")  gets you there.
>
> OK, good to know.  Thanks for helping.
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


probably this has used up sufficient disk space in the mail archive
already, but anyway a bit of support  to the initial request: one of the
very first things I did, when I started using R, was adding

cd <- setwd
pwd <- getwd

to my .Rprofile. and when I encouraged colleagues to try R out, the 'top
three' questions where

"how can I get out? I tried ^C, exit(), quit(), but nothing works"
"how can I change the directory? `cd' does'nt work"
"where am I? `pwd' does'nt work" (`pwd' is something like a 'local
speciality', I presume...)

this is of course a marginal obstacle for new users, but avoidable all
the same. (and maybe most people (like myself) in the first place don't
think it important enough to post it -- maybe it _would_ be in the FAQ
otherwise...)

so, _if_ 'cd' would be recognized in future releases, it would'nt do any
harm, would it?


joerg

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: Can't there be a cd command?

barry rowlingson

> so, _if_ 'cd' would be recognized in future releases, it would'nt do any
> harm, would it?

  > ls()
[1] some   things   here
  > cd("foo")
  > ls()
[1] some   things   here

Cue shout of: "Hey, it didnt work!"

ls() is not to /bin/ls what setwd() is to 'cd'.

Gets -1 from me. setwd() makes it clear[er] its a working directory on
the file system and nothing to do with R's objects.

Barry

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: Can't there be a cd command?

PaulJohnson32gmail
In reply to this post by Prof Brian Ripley
It is a FAQ in our Linux lab.  People start emacs and fire up R via
ess, and then they have no idea 'where they are".  For computer
experts, it is not a problem, but for people who don't know much about
computers, it is a pretty big problem.  They have data in some
subdirectory, but almost invariably they don't get emacs & R started
from that same place.

Unfortunately, for our users, it does not help to simply re-label
setwd as cd.  Both commands imply a deeper understanding of the OS
than they have.  Also, unfortunately, these are the same people who
don't understand that FAQs exist and should be consulted. These people
are so new/timid that asking in r-help would be the last thing to
cross their mind.

I've wondered if it would not help to have the R prompt include the
directory name, as in an x terminal.

pj

On 5/10/06, Prof Brian Ripley <[hidden email]> wrote:

>
> Exactly.  I don't think I have ever used setwd() on Linux.
>
> Also, I have never seen this asked before for a Unix-alike, so it seems
> not to be a >F<AQ.  There is a common tendency for users who run into a
> problem to think everyone does too, and it isn't necessarily so.
> Frequently asked questions do make it to the FAQs: it is a defence
> mechanism for the volunteers supporting R.
>
> help.search("directory")  gets you there.
>
> --
> Brian D. Ripley,                  [hidden email]
> 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
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>


--
Paul E. Johnson
Professor, Political Science
1541 Lilac Lane, Room 504
University of Kansas

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: Can't there be a cd command?

Liaw, Andy
In reply to this post by Issac Trotts
From: Paul Johnson
>
> It is a FAQ in our Linux lab.  People start emacs and fire up
> R via ess, and then they have no idea 'where they are".  For
> computer experts, it is not a problem, but for people who
> don't know much about computers, it is a pretty big problem.  
> They have data in some subdirectory, but almost invariably
> they don't get emacs & R started from that same place.

ESS by default will prompt for start-up directory when starting
R.  Perhaps that was turned off in the lab?

 
> Unfortunately, for our users, it does not help to simply
> re-label setwd as cd.  Both commands imply a deeper
> understanding of the OS than they have.  Also, unfortunately,
> these are the same people who don't understand that FAQs
> exist and should be consulted. These people are so new/timid
> that asking in r-help would be the last thing to cross their mind.
>
> I've wondered if it would not help to have the R prompt
> include the directory name, as in an x terminal.

Here's one possibility (on WinXP Pro):

> h <- taskCallbackManager()
> h$add(function(expr, value, ok, visible) {
+     options(prompt=paste(getwd(),"> ", sep=""))
+     return(TRUE)}, name="pwdprompt")
[1] "pwdprompt"
C:/home > setwd("projects")
C:/home/projects >

Andy

 

> pj
>
> On 5/10/06, Prof Brian Ripley <[hidden email]> wrote:
>
> >
> > Exactly.  I don't think I have ever used setwd() on Linux.
> >
> > Also, I have never seen this asked before for a Unix-alike, so it
> > seems not to be a >F<AQ.  There is a common tendency for
> users who run
> > into a problem to think everyone does too, and it isn't
> necessarily so.
> > Frequently asked questions do make it to the FAQs: it is a defence
> > mechanism for the volunteers supporting R.
> >
> > help.search("directory")  gets you there.
> >
> > --
> > Brian D. Ripley,                  [hidden email]
> > 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
> >
> > ______________________________________________
> > [hidden email] mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide!
> > http://www.R-project.org/posting-guide.html
> >
>
>
> --
> Paul E. Johnson
> Professor, Political Science
> 1541 Lilac Lane, Room 504
> University of Kansas
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: Can't there be a cd command?

Duncan Murdoch
In reply to this post by PaulJohnson32gmail
On 5/10/2006 9:29 AM, Paul Johnson wrote:

> It is a FAQ in our Linux lab.  People start emacs and fire up R via
> ess, and then they have no idea 'where they are".  For computer
> experts, it is not a problem, but for people who don't know much about
> computers, it is a pretty big problem.  They have data in some
> subdirectory, but almost invariably they don't get emacs & R started
> from that same place.
>
> Unfortunately, for our users, it does not help to simply re-label
> setwd as cd.  Both commands imply a deeper understanding of the OS
> than they have.  Also, unfortunately, these are the same people who
> don't understand that FAQs exist and should be consulted. These people
> are so new/timid that asking in r-help would be the last thing to
> cross their mind.
>
> I've wondered if it would not help to have the R prompt include the
> directory name, as in an x terminal.

I think file system directories aren't as central in R as they are in a
shell, so it would just be distracting.  Most of the time I work in the
R workspace, not in the file system.

To me the solution is to allow interactive file selection by default,
i.e. the default on read.table and similar functions should be
file.choose(), rather than having no default and throwing an error.
This won't help you in the short run (because file.choose() on Linux
isn't all that friendly to beginners), but perhaps it would encourage
someone to make it better.  file.choose() is quite nice in Windows (and
I think on the Mac), so beginners there could be told

mydf <- read.table()

and they'd get something useful.

Martin Maechler has disagreed with me about this in the past, but hasn't
convinced me that he's right, he's just convinced me that doing nothing
is easier than arguing about it.

Duncan Murdoch

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: Can't there be a cd command?

Duncan Murdoch
In reply to this post by Liaw, Andy
On 5/10/2006 10:11 AM, Liaw, Andy wrote:

> From: Paul Johnson
>>
>> It is a FAQ in our Linux lab.  People start emacs and fire up
>> R via ess, and then they have no idea 'where they are".  For
>> computer experts, it is not a problem, but for people who
>> don't know much about computers, it is a pretty big problem.  
>> They have data in some subdirectory, but almost invariably
>> they don't get emacs & R started from that same place.
>
> ESS by default will prompt for start-up directory when starting
> R.  Perhaps that was turned off in the lab?
>
>  
>> Unfortunately, for our users, it does not help to simply
>> re-label setwd as cd.  Both commands imply a deeper
>> understanding of the OS than they have.  Also, unfortunately,
>> these are the same people who don't understand that FAQs
>> exist and should be consulted. These people are so new/timid
>> that asking in r-help would be the last thing to cross their mind.
>>
>> I've wondered if it would not help to have the R prompt
>> include the directory name, as in an x terminal.
>
> Here's one possibility (on WinXP Pro):
>
>> h <- taskCallbackManager()
>> h$add(function(expr, value, ok, visible) {
> +     options(prompt=paste(getwd(),"> ", sep=""))
> +     return(TRUE)}, name="pwdprompt")
> [1] "pwdprompt"
> C:/home > setwd("projects")
> C:/home/projects >

That doesn't quite work in the current Rgui, because the menu function
to change directories (File | Change dir...) doesn't trigger the
callback.  Not sure if that's a bug or not...

Duncan Murdoch

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: Can't there be a cd command?

Gabor Grothendieck
In reply to this post by Duncan Murdoch
On 5/10/06, Duncan Murdoch <[hidden email]> wrote:

> On 5/10/2006 9:29 AM, Paul Johnson wrote:
> > It is a FAQ in our Linux lab.  People start emacs and fire up R via
> > ess, and then they have no idea 'where they are".  For computer
> > experts, it is not a problem, but for people who don't know much about
> > computers, it is a pretty big problem.  They have data in some
> > subdirectory, but almost invariably they don't get emacs & R started
> > from that same place.
> >
> > Unfortunately, for our users, it does not help to simply re-label
> > setwd as cd.  Both commands imply a deeper understanding of the OS
> > than they have.  Also, unfortunately, these are the same people who
> > don't understand that FAQs exist and should be consulted. These people
> > are so new/timid that asking in r-help would be the last thing to
> > cross their mind.
> >
> > I've wondered if it would not help to have the R prompt include the
> > directory name, as in an x terminal.
>
> I think file system directories aren't as central in R as they are in a
> shell, so it would just be distracting.  Most of the time I work in the
> R workspace, not in the file system.
>
> To me the solution is to allow interactive file selection by default,
> i.e. the default on read.table and similar functions should be
> file.choose(), rather than having no default and throwing an error.
> This won't help you in the short run (because file.choose() on Linux
> isn't all that friendly to beginners), but perhaps it would encourage
> someone to make it better.  file.choose() is quite nice in Windows (and
> I think on the Mac), so beginners there could be told
>
> mydf <- read.table()
>
> and they'd get something useful.
>
> Martin Maechler has disagreed with me about this in the past, but hasn't
> convinced me that he's right, he's just convinced me that doing nothing
> is easier than arguing about it.

I agree with Martin regarding read.table; however, the underlying idea is
good and could be achieved via simple wrappers which are the same
as the corresponding underlying functions except for the default argument
to file:

   read.table.choose <- function(file = file.choose(), ...)
read.table(file, ...)
   read.csv.choose <- function(file = file.choose(), ...) read.csv(file, ...)
   read.delim.choose <- function(file = file.choose(), ...)
read.delim(file, ...)

  # test
  mydata <- read.table.choose()

in a package available to the users or possibly even in R core.

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: Can't there be a cd command?

Duncan Murdoch
On 5/10/2006 10:45 AM, Gabor Grothendieck wrote:

> On 5/10/06, Duncan Murdoch <[hidden email]> wrote:
>> On 5/10/2006 9:29 AM, Paul Johnson wrote:
>> > It is a FAQ in our Linux lab.  People start emacs and fire up R via
>> > ess, and then they have no idea 'where they are".  For computer
>> > experts, it is not a problem, but for people who don't know much about
>> > computers, it is a pretty big problem.  They have data in some
>> > subdirectory, but almost invariably they don't get emacs & R started
>> > from that same place.
>> >
>> > Unfortunately, for our users, it does not help to simply re-label
>> > setwd as cd.  Both commands imply a deeper understanding of the OS
>> > than they have.  Also, unfortunately, these are the same people who
>> > don't understand that FAQs exist and should be consulted. These people
>> > are so new/timid that asking in r-help would be the last thing to
>> > cross their mind.
>> >
>> > I've wondered if it would not help to have the R prompt include the
>> > directory name, as in an x terminal.
>>
>> I think file system directories aren't as central in R as they are in a
>> shell, so it would just be distracting.  Most of the time I work in the
>> R workspace, not in the file system.
>>
>> To me the solution is to allow interactive file selection by default,
>> i.e. the default on read.table and similar functions should be
>> file.choose(), rather than having no default and throwing an error.
>> This won't help you in the short run (because file.choose() on Linux
>> isn't all that friendly to beginners), but perhaps it would encourage
>> someone to make it better.  file.choose() is quite nice in Windows (and
>> I think on the Mac), so beginners there could be told
>>
>> mydf <- read.table()
>>
>> and they'd get something useful.
>>
>> Martin Maechler has disagreed with me about this in the past, but hasn't
>> convinced me that he's right, he's just convinced me that doing nothing
>> is easier than arguing about it.
>
> I agree with Martin regarding read.table; however, the underlying idea is
> good and could be achieved via simple wrappers which are the same
> as the corresponding underlying functions except for the default argument
> to file:
>
>    read.table.choose <- function(file = file.choose(), ...)
> read.table(file, ...)
>    read.csv.choose <- function(file = file.choose(), ...) read.csv(file, ...)
>    read.delim.choose <- function(file = file.choose(), ...)
> read.delim(file, ...)
>
>   # test
>   mydata <- read.table.choose()
>
> in a package available to the users or possibly even in R core.

No, I don't think this is a good idea.  It would be just as easy to tell
people to type

read.table(file=file.choose())

with no new package or function necessary.  I want the existing basic
function to work when used by a beginner in a simple way.

What is it that you find objectionable about having a default for the
file argument in read.table?  I think Martin has said that he doesn't
want non-UI functions to be involved with UI functions, but I don't see
that:  if your code works now, it will be completely unaffected by
setting a default for the argument.  (Sorry if I summarized the argument
incorrectly, Martin, I didn't look it up.)

Duncan Murdoch

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: Can't there be a cd command?

Gabor Grothendieck
On 5/10/06, Duncan Murdoch <[hidden email]> wrote:

> On 5/10/2006 10:45 AM, Gabor Grothendieck wrote:
> > On 5/10/06, Duncan Murdoch <[hidden email]> wrote:
> >> On 5/10/2006 9:29 AM, Paul Johnson wrote:
> >> > It is a FAQ in our Linux lab.  People start emacs and fire up R via
> >> > ess, and then they have no idea 'where they are".  For computer
> >> > experts, it is not a problem, but for people who don't know much about
> >> > computers, it is a pretty big problem.  They have data in some
> >> > subdirectory, but almost invariably they don't get emacs & R started
> >> > from that same place.
> >> >
> >> > Unfortunately, for our users, it does not help to simply re-label
> >> > setwd as cd.  Both commands imply a deeper understanding of the OS
> >> > than they have.  Also, unfortunately, these are the same people who
> >> > don't understand that FAQs exist and should be consulted. These people
> >> > are so new/timid that asking in r-help would be the last thing to
> >> > cross their mind.
> >> >
> >> > I've wondered if it would not help to have the R prompt include the
> >> > directory name, as in an x terminal.
> >>
> >> I think file system directories aren't as central in R as they are in a
> >> shell, so it would just be distracting.  Most of the time I work in the
> >> R workspace, not in the file system.
> >>
> >> To me the solution is to allow interactive file selection by default,
> >> i.e. the default on read.table and similar functions should be
> >> file.choose(), rather than having no default and throwing an error.
> >> This won't help you in the short run (because file.choose() on Linux
> >> isn't all that friendly to beginners), but perhaps it would encourage
> >> someone to make it better.  file.choose() is quite nice in Windows (and
> >> I think on the Mac), so beginners there could be told
> >>
> >> mydf <- read.table()
> >>
> >> and they'd get something useful.
> >>
> >> Martin Maechler has disagreed with me about this in the past, but hasn't
> >> convinced me that he's right, he's just convinced me that doing nothing
> >> is easier than arguing about it.
> >
> > I agree with Martin regarding read.table; however, the underlying idea is
> > good and could be achieved via simple wrappers which are the same
> > as the corresponding underlying functions except for the default argument
> > to file:
> >
> >    read.table.choose <- function(file = file.choose(), ...)
> > read.table(file, ...)
> >    read.csv.choose <- function(file = file.choose(), ...) read.csv(file, ...)
> >    read.delim.choose <- function(file = file.choose(), ...)
> > read.delim(file, ...)
> >
> >   # test
> >   mydata <- read.table.choose()
> >
> > in a package available to the users or possibly even in R core.
>
> No, I don't think this is a good idea.  It would be just as easy to tell
> people to type
>
> read.table(file=file.choose())
>
> with no new package or function necessary.  I want the existing basic
> function to work when used by a beginner in a simple way.

I don't think that an idiom of multiple function calls is as simple as
issuing a single function call with no args.

One possibility is to have
a keyword "choose" on the file function in the same way that file
accepts the keyword "clipboard".  Then one could write:

  mydata <- read.table("choose")

I think the wrapper approach is probably preferable though and seems
consistent with the way R deals with this in other places such as the
ISOdate wrapper.


>
> What is it that you find objectionable about having a default for the
> file argument in read.table?  I think Martin has said that he doesn't
> want non-UI functions to be involved with UI functions, but I don't see
> that:  if your code works now, it will be completely unaffected by
> setting a default for the argument.  (Sorry if I summarized the argument
> incorrectly, Martin, I didn't look it up.)

That would be my objection too.  UI should not be tied to the non-UI core.
Its basically a loose coupling argument.

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: Can't there be a cd command?

Duncan Murdoch
On 5/10/2006 11:10 AM, Gabor Grothendieck wrote:

> On 5/10/06, Duncan Murdoch <[hidden email]> wrote:
>> On 5/10/2006 10:45 AM, Gabor Grothendieck wrote:
>> > On 5/10/06, Duncan Murdoch <[hidden email]> wrote:
>> >> On 5/10/2006 9:29 AM, Paul Johnson wrote:
>> >> > It is a FAQ in our Linux lab.  People start emacs and fire up R via
>> >> > ess, and then they have no idea 'where they are".  For computer
>> >> > experts, it is not a problem, but for people who don't know much about
>> >> > computers, it is a pretty big problem.  They have data in some
>> >> > subdirectory, but almost invariably they don't get emacs & R started
>> >> > from that same place.
>> >> >
>> >> > Unfortunately, for our users, it does not help to simply re-label
>> >> > setwd as cd.  Both commands imply a deeper understanding of the OS
>> >> > than they have.  Also, unfortunately, these are the same people who
>> >> > don't understand that FAQs exist and should be consulted. These people
>> >> > are so new/timid that asking in r-help would be the last thing to
>> >> > cross their mind.
>> >> >
>> >> > I've wondered if it would not help to have the R prompt include the
>> >> > directory name, as in an x terminal.
>> >>
>> >> I think file system directories aren't as central in R as they are in a
>> >> shell, so it would just be distracting.  Most of the time I work in the
>> >> R workspace, not in the file system.
>> >>
>> >> To me the solution is to allow interactive file selection by default,
>> >> i.e. the default on read.table and similar functions should be
>> >> file.choose(), rather than having no default and throwing an error.
>> >> This won't help you in the short run (because file.choose() on Linux
>> >> isn't all that friendly to beginners), but perhaps it would encourage
>> >> someone to make it better.  file.choose() is quite nice in Windows (and
>> >> I think on the Mac), so beginners there could be told
>> >>
>> >> mydf <- read.table()
>> >>
>> >> and they'd get something useful.
>> >>
>> >> Martin Maechler has disagreed with me about this in the past, but hasn't
>> >> convinced me that he's right, he's just convinced me that doing nothing
>> >> is easier than arguing about it.
>> >
>> > I agree with Martin regarding read.table; however, the underlying idea is
>> > good and could be achieved via simple wrappers which are the same
>> > as the corresponding underlying functions except for the default argument
>> > to file:
>> >
>> >    read.table.choose <- function(file = file.choose(), ...)
>> > read.table(file, ...)
>> >    read.csv.choose <- function(file = file.choose(), ...) read.csv(file, ...)
>> >    read.delim.choose <- function(file = file.choose(), ...)
>> > read.delim(file, ...)
>> >
>> >   # test
>> >   mydata <- read.table.choose()
>> >
>> > in a package available to the users or possibly even in R core.
>>
>> No, I don't think this is a good idea.  It would be just as easy to tell
>> people to type
>>
>> read.table(file=file.choose())
>>
>> with no new package or function necessary.  I want the existing basic
>> function to work when used by a beginner in a simple way.
>
> I don't think that an idiom of multiple function calls is as simple as
> issuing a single function call with no args.
>
> One possibility is to have
> a keyword "choose" on the file function in the same way that file
> accepts the keyword "clipboard".  Then one could write:
>
>   mydata <- read.table("choose")
>
> I think the wrapper approach is probably preferable though and seems
> consistent with the way R deals with this in other places such as the
> ISOdate wrapper.
>
>
>>
>> What is it that you find objectionable about having a default for the
>> file argument in read.table?  I think Martin has said that he doesn't
>> want non-UI functions to be involved with UI functions, but I don't see
>> that:  if your code works now, it will be completely unaffected by
>> setting a default for the argument.  (Sorry if I summarized the argument
>> incorrectly, Martin, I didn't look it up.)
>
> That would be my objection too.  UI should not be tied to the non-UI core.
> Its basically a loose coupling argument.

I don't accept that argument, because in R everything* is interactive.
There isn't a non-UI core.  The function arguments are part of the user
interface.

Duncan Murdoch

* Well, maybe this should be restricted to functions visible to the
user, but everything we've been discussing so far is visible and is part
of the user interface.

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: Can't there be a cd command?

Jan T. Kim
On Wed, May 10, 2006 at 11:26:55AM -0400, Duncan Murdoch wrote:
> On 5/10/2006 11:10 AM, Gabor Grothendieck wrote:
> > On 5/10/06, Duncan Murdoch <[hidden email]> wrote:

> >> What is it that you find objectionable about having a default for the
> >> file argument in read.table?  I think Martin has said that he doesn't
> >> want non-UI functions to be involved with UI functions, but I don't see
> >> that:  if your code works now, it will be completely unaffected by
> >> setting a default for the argument.  (Sorry if I summarized the argument
> >> incorrectly, Martin, I didn't look it up.)
> >
> > That would be my objection too.  UI should not be tied to the non-UI core.
> > Its basically a loose coupling argument.
>
> I don't accept that argument, because in R everything* is interactive.
> There isn't a non-UI core.  The function arguments are part of the user
> interface.

It seems to me that there might be a misunderstanding here; as the term
"user" is used to refer to a person interacting with the computer on
the one hand, and to refer to a programmer using R on the other hand.

Everything being "part of the user interface", in the sense of
every user-visible function being part of the API, does not and should
not imply that everything should be interactive.

In my experience, interactivity is a rather double-edged thing: On the
one hand, it facilitates learning and exploration, but on the other
hand, its improper use is frequently detrimental to reproducibility of
scientific computation.

Best regards, Jan
--
 +- Jan T. Kim -------------------------------------------------------+
 |             email: [hidden email]                               |
 |             WWW:   http://www.cmp.uea.ac.uk/people/jtk             |
 *-----=<  hierarchical systems are for files, not for humans  >=-----*

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: Can't there be a cd command?

Gabor Grothendieck
In reply to this post by Duncan Murdoch
On 5/10/06, Duncan Murdoch <[hidden email]> wrote:

> On 5/10/2006 11:10 AM, Gabor Grothendieck wrote:
> > On 5/10/06, Duncan Murdoch <[hidden email]> wrote:
> >> On 5/10/2006 10:45 AM, Gabor Grothendieck wrote:
> >> > On 5/10/06, Duncan Murdoch <[hidden email]> wrote:
> >> >> On 5/10/2006 9:29 AM, Paul Johnson wrote:
> >> >> > It is a FAQ in our Linux lab.  People start emacs and fire up R via
> >> >> > ess, and then they have no idea 'where they are".  For computer
> >> >> > experts, it is not a problem, but for people who don't know much about
> >> >> > computers, it is a pretty big problem.  They have data in some
> >> >> > subdirectory, but almost invariably they don't get emacs & R started
> >> >> > from that same place.
> >> >> >
> >> >> > Unfortunately, for our users, it does not help to simply re-label
> >> >> > setwd as cd.  Both commands imply a deeper understanding of the OS
> >> >> > than they have.  Also, unfortunately, these are the same people who
> >> >> > don't understand that FAQs exist and should be consulted. These people
> >> >> > are so new/timid that asking in r-help would be the last thing to
> >> >> > cross their mind.
> >> >> >
> >> >> > I've wondered if it would not help to have the R prompt include the
> >> >> > directory name, as in an x terminal.
> >> >>
> >> >> I think file system directories aren't as central in R as they are in a
> >> >> shell, so it would just be distracting.  Most of the time I work in the
> >> >> R workspace, not in the file system.
> >> >>
> >> >> To me the solution is to allow interactive file selection by default,
> >> >> i.e. the default on read.table and similar functions should be
> >> >> file.choose(), rather than having no default and throwing an error.
> >> >> This won't help you in the short run (because file.choose() on Linux
> >> >> isn't all that friendly to beginners), but perhaps it would encourage
> >> >> someone to make it better.  file.choose() is quite nice in Windows (and
> >> >> I think on the Mac), so beginners there could be told
> >> >>
> >> >> mydf <- read.table()
> >> >>
> >> >> and they'd get something useful.
> >> >>
> >> >> Martin Maechler has disagreed with me about this in the past, but hasn't
> >> >> convinced me that he's right, he's just convinced me that doing nothing
> >> >> is easier than arguing about it.
> >> >
> >> > I agree with Martin regarding read.table; however, the underlying idea is
> >> > good and could be achieved via simple wrappers which are the same
> >> > as the corresponding underlying functions except for the default argument
> >> > to file:
> >> >
> >> >    read.table.choose <- function(file = file.choose(), ...)
> >> > read.table(file, ...)
> >> >    read.csv.choose <- function(file = file.choose(), ...) read.csv(file, ...)
> >> >    read.delim.choose <- function(file = file.choose(), ...)
> >> > read.delim(file, ...)
> >> >
> >> >   # test
> >> >   mydata <- read.table.choose()
> >> >
> >> > in a package available to the users or possibly even in R core.
> >>
> >> No, I don't think this is a good idea.  It would be just as easy to tell
> >> people to type
> >>
> >> read.table(file=file.choose())
> >>
> >> with no new package or function necessary.  I want the existing basic
> >> function to work when used by a beginner in a simple way.
> >
> > I don't think that an idiom of multiple function calls is as simple as
> > issuing a single function call with no args.
> >
> > One possibility is to have
> > a keyword "choose" on the file function in the same way that file
> > accepts the keyword "clipboard".  Then one could write:
> >
> >   mydata <- read.table("choose")
> >
> > I think the wrapper approach is probably preferable though and seems
> > consistent with the way R deals with this in other places such as the
> > ISOdate wrapper.
> >
> >
> >>
> >> What is it that you find objectionable about having a default for the
> >> file argument in read.table?  I think Martin has said that he doesn't
> >> want non-UI functions to be involved with UI functions, but I don't see
> >> that:  if your code works now, it will be completely unaffected by
> >> setting a default for the argument.  (Sorry if I summarized the argument
> >> incorrectly, Martin, I didn't look it up.)
> >
> > That would be my objection too.  UI should not be tied to the non-UI core.
> > Its basically a loose coupling argument.
>
> I don't accept that argument, because in R everything* is interactive.
> There isn't a non-UI core.  The function arguments are part of the user
> interface.
>
> Duncan Murdoch
>
> * Well, maybe this should be restricted to functions visible to the
> user, but everything we've been discussing so far is visible and is part
> of the user interface.
>

Another idea is to implement a menu item in the Windows GUI that
does a read.table(file.choose(), ...).

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: Can't there be a cd command?

Duncan Murdoch
In reply to this post by Jan T. Kim
On 5/10/2006 12:15 PM, Jan T. Kim wrote:

> On Wed, May 10, 2006 at 11:26:55AM -0400, Duncan Murdoch wrote:
>> On 5/10/2006 11:10 AM, Gabor Grothendieck wrote:
>> > On 5/10/06, Duncan Murdoch <[hidden email]> wrote:
>
>> >> What is it that you find objectionable about having a default for the
>> >> file argument in read.table?  I think Martin has said that he doesn't
>> >> want non-UI functions to be involved with UI functions, but I don't see
>> >> that:  if your code works now, it will be completely unaffected by
>> >> setting a default for the argument.  (Sorry if I summarized the argument
>> >> incorrectly, Martin, I didn't look it up.)
>> >
>> > That would be my objection too.  UI should not be tied to the non-UI core.
>> > Its basically a loose coupling argument.
>>
>> I don't accept that argument, because in R everything* is interactive.
>> There isn't a non-UI core.  The function arguments are part of the user
>> interface.
>
> It seems to me that there might be a misunderstanding here; as the term
> "user" is used to refer to a person interacting with the computer on
> the one hand, and to refer to a programmer using R on the other hand.

One of the design goals of S and R is to blur the distinction between
users and programmers.  It is a continuum.  R is designed to gently urge
non-programmers to become programmers, because the designers think
that's the way statistical computing should be done.

> Everything being "part of the user interface", in the sense of
> every user-visible function being part of the API, does not and should
> not imply that everything should be interactive.

No, I didn't suggest that.  What I was suggesting is that it should be
*convenient* to use read.table interactively, not that it should be
required. (It's already possible, but not convenient, especially for a
beginner who doesn't know the secret incantation.)

> In my experience, interactivity is a rather double-edged thing: On the
> one hand, it facilitates learning and exploration, but on the other
> hand, its improper use is frequently detrimental to reproducibility of
> scientific computation.

I definitely agree with that.  It should be convenient to use R
non-interactively as well.  Anyone who wants reproducibility should be
writing packages and scripts or vignettes that run non-interactively.
That's why I am emphasizing that this change will have no effect on
existing code.  I wouldn't suggest it if it did.

Duncan Murdoch

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
12