Thursday, January 22, 2015 10:29 AM
To: Bert Gunter
Cc: William Dunlap; r-help@r-project.org; Ravi Varadhan
Subject: Re: [R] Re-order levels of a categorical (factor) variable
>>>>> Bert Gunter
>>>>> on Wed, 21 Jan 2015 18:52:12 -0800 writes:
> Bill/Rav
> Bert Gunter
> on Wed, 21 Jan 2015 18:52:12 -0800 writes:
> Bill/Ravi:
> I believe the problem is that the factor is automatically created when
> a data frame is created by read.table(). By default, the levels are
> lexicographically ordered. The following reproduces
Bill/Ravi:
I believe the problem is that the factor is automatically created when
a data frame is created by read.table(). By default, the levels are
lexicographically ordered. The following reproduces the problem and
gives a solution.
>library(lattice)
> z <- data.frame(y = 1:9, x = rep(c("pre"
Are you sure the factors of T are in the order you think they are? (Are you
sure you are using the expected version of T.) Use print(levels(T)) to
make
sure.
I tried
timeCats <- c("Presurgery", "Day 30", "Day 60", "Day 180", "Day 365")
d <- data.frame(T = factor(rep(timeCats, 11:15), lev
4 matches
Mail list logo