Dear all,
I have noticed a little change in the behaviour of as.factor from R-2.2.1 to
R-2.3.0, and can't find it in the NEWS.

In R-2.3.0:
> times <- 1:5
> class(times) <- "Date"
> as.factor(times)
[1] 1 2 3 4 5
Levels: 1 2 3 4 5

In R-2.2.1:
> as.factor(times)
[1] 1970-01-02 1970-01-03 1970-01-04 1970-01-05 1970-01-06
Levels: 1970-01-02 1970-01-03 1970-01-04 1970-01-05 1970-01-06

Is this the intended behaviour?
Note that the change is reflected on other functions which seems to use
as.factor internally, for example 'tapply'.
Consider the following code:

times <- 1:5
class(times) <- "Date"
id <- rep(times, each=2)
vals <- rep(1:2,5)
tapply(vals, id, mean)

Under R-2.2.1 this gives:
1970-01-02 1970-01-03 1970-01-04 1970-01-05 1970-01-06
       1.5        1.5        1.5        1.5        1.5

But under R-2.3.0 the output is:
 1   2   3   4   5
1.5 1.5 1.5 1.5 1.5

Antonio, Fabio Di Narzo.

        [[alternative HTML version deleted]]

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

Reply via email to