From murdoch.duncan at gmail.com  Thu Sep  9 12:43:47 2010
From: murdoch.duncan at gmail.com (Duncan Murdoch)
Date: Thu, 09 Sep 2010 06:43:47 -0400
Subject: [Rd] An ls error which is not an error...
In-Reply-To: <AANLkTinh9C-+sWLs8Fv9vKmiWP+9O99M7w2gKcGhD4g3@mail.gmail.com>
References: <AANLkTinh9C-+sWLs8Fv9vKmiWP+9O99M7w2gKcGhD4g3@mail.gmail.com>
Message-ID: <4C88BA63.1090601@gmail.com>

On 09/09/2010 5:57 AM, Barry Rowlingson wrote:
> If I try ls with an unquoted version of something in my search list, I
> get an error message but the ls completes successfully. For example:
> 
>  > attach("x.RData")
>  > ls(file:x.RData)
>  Error in try(name) : object 'x.RData' not found
>  [1] "x"
> 
> which seems to be because ls first does: nameValue <- try(name) which
> raises the error, and then goes on to do some
> substitute(deparse(magic)) to get the name and carries on as if I'd
> done ls("file:x.RData")
> 
> Documentation says (with my enumeration):
> 
>     The ?name? argument can specify the environment from which object
>      names are taken in one of several forms:
> 
>     1. as an integer (the position in the ?search? list);
>     2. as the character string name of an element in the search list;
>     3.  or as an explicit ?environment?
> 
> Either ls(file:x.RData) is none of these in which case there should be
> an error and exit, or it's (2), in which case the error is misleading.
> I think try(name,silent=TRUE) might be a better option?

This is old code, so I don't think converting it to an error is a good 
idea.  I don't like the idea of silently eating the error:  it might 
have been a typo, that just coincidentally looks like the name of 
something on the search list.  So I will try to change the error to an 
informative warning.

Duncan Murdoch



[Rd] An ls error which is not an error...
Duncan Murdoch