?as.list states that as.list can be used with environments as arguments
(what is referred to there as the '"environment" method for as.list). 
indeed,

    e = globalenv()
    as.list(e)
    # $e
    # <environment: R_GlobalEnv>

however, it seems to have problems with environment objects with a class
attribute:

    e = structure(globalenv(), class='foo')
    as.list(e)
    # Error in as.vector(x, "list") :
    #  cannot coerce type 'environment' to vector of type 'list'

the error message is misleading.  instead of complaining about the class
'foo', it says that as.list cannot coerce an environment to a list,
which is nonsense, since this is precisely what it does in the first
example above, and what is also clear from ?as.list:

"
 The '"environment"' method for 'as.list' copies the name-value
     pairs (for names not beginning with a dot) from an environment to
     a named list.
"

a different error message might be more appropriate.

vQ

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to