Hoi Peter,

--On woensdag 16 juni 2004 17:35 +0200 Peter Dalgaard <[EMAIL PROTECTED]> wrote:
Anyways, the way out is

 d2 <- subset(dd,c==1)
 ifac <- sapply(dd,is.factor)
 d2[ifac] <- lapply(d2[ifac],factor)

or

 d2 <- subset(dd,c==1)
 d2[] <- lapply(d2, function(x) if (is.factor(x)) factor(x) else x)

My toolbox.r now contains:

my.subset <- function(x, drop.unused.levels=FALSE, ...) {
 subsetted <- subset(x, ...)

 if (drop.unused.levels) {
   subsetted[] <- lapply(subsetted,
                     function(x) if (is.factor(x)) factor(x) else x)
 }

 subsetted
}


Thnx for all the help!



--
Paul Lemmens
NICI, University of Nijmegen              ASCII Ribbon Campaign /"\
Montessorilaan 3 (B.01.05)                    Against HTML Mail \ /
NL-6525 HR Nijmegen                                              X
The Netherlands                                                 / \
Phonenumber    +31-24-3612648
Fax            +31-24-3616066

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to