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

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Thu Sep 9 11:57:46 CEST 2010


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?

Barry



More information about the R-devel mailing list