Seth Falcon
2006-Oct-15 18:48 UTC
[Rd] Feature request: names(someEnv) same as ls(someEnv)
Hi, I would be nice if names() returned the equivalent of ls() for environments. --- a/src/main/attrib.c +++ b/src/main/attrib.c @@ -687,6 +687,8 @@ SEXP attribute_hidden do_names(SEXP call s = CAR(args); if (isVector(s) || isList(s) || isLanguage(s)) return getAttrib(s, R_NamesSymbol); + if (isEnvironment(s)) + return R_lsInternal(s, 0); return R_NilValue; } + seth -- Seth Falcon | Computational Biology | Fred Hutchinson Cancer Research Center bioconductor.org
Duncan Murdoch
2006-Oct-15 19:04 UTC
[Rd] Feature request: names(someEnv) same as ls(someEnv)
On 10/15/2006 2:48 PM, Seth Falcon wrote:> Hi, > > I would be nice if names() returned the equivalent of ls() for > environments.Wouldn't that just confuse people into thinking that environments are vectors? Wouldn't it then be reasonable to assume that env[[which(names(env) == "foo")]] would be a synonym for env$foo? I don't see why this would be nice: why not just use ls()? Duncan Murdoch> > --- a/src/main/attrib.c > +++ b/src/main/attrib.c > @@ -687,6 +687,8 @@ SEXP attribute_hidden do_names(SEXP call > s = CAR(args); > if (isVector(s) || isList(s) || isLanguage(s)) > return getAttrib(s, R_NamesSymbol); > + if (isEnvironment(s)) > + return R_lsInternal(s, 0); > return R_NilValue; > } > > > + seth > > -- > Seth Falcon | Computational Biology | Fred Hutchinson Cancer Research Center > bioconductor.org > > ______________________________________________ > R-devel at r-project.org mailing list > stat.ethz.ch/mailman/listinfo/r-devel