From murdoch at stats.uwo.ca  Mon Jan 30 00:03:34 2006
From: murdoch at stats.uwo.ca (Duncan Murdoch)
Date: Sun, 29 Jan 2006 18:03:34 -0500
Subject: [Rd] [R] help with read.table() function
In-Reply-To: <971536df0601291420g5dd9732dl2108a5661705d7e2@mail.gmail.com>
References: <20060129162850.73978.qmail@web33204.mail.mud.yahoo.com>	
	<43DCF7E8.2080900@stats.uwo.ca>	
	<971536df0601291024n57113e97t3cc938a78a11f495@mail.gmail.com>	
	<43DD3D75.6010404@stats.uwo.ca>
	<971536df0601291420g5dd9732dl2108a5661705d7e2@mail.gmail.com>
Message-ID: <43DD49C6.201@stats.uwo.ca>

On 1/29/2006 5:20 PM, Gabor Grothendieck wrote:
> On 1/29/06, Duncan Murdoch <murdoch at stats.uwo.ca> wrote:
>> On 1/29/2006 1:24 PM, Gabor Grothendieck wrote:
>>  > Normally one expects stdin to be the default on command line
>>  > programs and something like file.choose to be the default on GUI
>>  > programs and this would break that expectation.
>>
>> We don't currently meet that expectation, so I don't think it would make
>> things any worse.  As I mentioned to Brian, I wouldn't change the
> 
> II don't think you understood my point.  This is how most software works,
> IN GENERAL, so R should be expected to work that way
> too.   

I think I understood that, but my point is that R doesn't act that way 
now, and this change won't make the situation worse.

 >I don't think not having a default is so bad but having the wrong
> default that breaks the stereotype that one expects in all software
> is bad.

I don't follow your argument.  Why is it better to say

Error in read.table() : argument "file" is missing, with no default

than it would be to ask the user which file to read?  The first is 
unexpected in both of the situations you described, while the second is 
only unexpected in a command line program.

Consistency is a good thing, but there are a number of choices of what 
to be consistent with:

  - other similar functions in R (but they are inconsistent)
  - previous versions of R (which is why I wouldn't change scan())
  - other software a user would be familiar with (which is why 
file.choose() is a good idea in a GUI, but not in a command line program).

> What could be done is to add something about file.choose to the
> error message that one gets when one does read.table("myfile")
> and it can't find "myfile".

Currently our error messages explain what went wrong, they generally 
don't try to suggest alternative approaches (though a few do, e.g. 
help("dfdsfs")).  There are a lot of reasons read.table() could fail, 
and I think it would be very hard to get a good automatic rule on when 
file.choose() was the appropriate alternative.

Duncan Murdoch



[Rd] [R] help with read.table() function
Duncan Murdoch