[Rd] apply: new behaviour for factors in R-2.4.0

From: Christoph Buser <buser_at_stat.math.ethz.ch>
Date: Mon 25 Sep 2006 - 11:57:57 GMT


Dear R-core

There is a different output for the apply function due to the change of unlist as mentioned in the R news.

Newly, applying as.factor() (or factor()) in

str(dat <- data.frame(x = 1:10, f1 = gl(2,5,labels = c("A", "B")))) (d1 <- apply(dat,2,as.factor))

newly returns a character matrix while in R-2.3.1 the same command resulted in an integer matrix that was consistent (up to the ordering of the factor levels) with data.matrix().

The change is caused by the change of unlist() that, used for a list of factors, newly returns a single factor instead of an integer. I am happy with this change, but:

Is it desirable to change apply so that it does not return a character matrix in the example above or include a warning for such a case?

Thank you very much for an answer.

Regards,

Christoph Buser



Christoph Buser <buser@stat.math.ethz.ch> Seminar fuer Statistik, LEO C13
ETH Zurich	8092 Zurich	 SWITZERLAND
phone: x-41-44-632-4673		fax: 632-1228

http://stat.ethz.ch/~buser/

R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Mon Sep 25 22:08:09 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Mon 25 Sep 2006 - 14:30:10 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.