On Thu, 28 Sep 2006, Christoph Buser wrote:
> Dear Brian
>
> Thank you for your answer and the comment you included on the
> apply() help page.
>
> 1)
>
> You are correct. My data.frame is coerced into a matrix in
> apply()
>
> 2)
>
> I agree that the new version of unlist() is better and works
>
Dear Brian
Thank you for your answer and the comment you included on the
apply() help page.
1)
You are correct. My data.frame is coerced into a matrix in
apply()
2)
I agree that the new version of unlist() is better and works
correctly and that in array() (due to as.vector()) the factor
"ans"
Christoph,
This is more complicated than your analysis.
1) apply takes a matrix as an argument, not a data frame, and so first
coerced 'dat' to a character matrix.
2) unlist is working quite correctly. The issue is array(), which
contains as.vector(data). Thus although the result could be a
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