On Wed, Oct 12, 2011 at 8:46 AM, Erin Hodgess <erinm.hodg...@gmail.com> wrote:
> Dear R People:
>
> Here is a really goofy question.
>
> I have some objects which have 2 classes: data.frame and ucr.
>
> Also, the classes will always be in that order.
>
> I have tried all sorts of things, but to no avail.
>
> listucrModels <- function(envir=.GlobalEnv, ...) {
>    objects <- ls(envir=envir, ...)
>    if (length(objects) == 0) NULL
>    else objects[sapply(objects,
>       function(.x)  "ucr"==
>       (class(eval(parse(text=.x), envir=envir))[2]))]
>    }
>

 Can you get away with just testing inherits(x,"ucr") or "ucr" %in%
class(x)? Or do you really have to test that "ucr" is the second
element? Do you have objects of class "ucr" that aren't also of class
"data.frame"?

______________________________________________
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