Skip to content

"chronological" ordering of factor in lm() and plot()

2 messages · Bill Venables, Eric C. Jennings

#
First put
then
will ensure the ordering you want.

Bill Venables.

-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Eric C. Jennings
Sent: Saturday, 16 April 2005 2:29 PM
To: R-help
Subject: [R] "chronological" ordering of factor in lm() and plot()


I am trying to do some basic regression and ANOVA on cycle times
(numeric
vectors) across weekdays (character vector), where I have simply
labelled my
days as:
days<- c("mon","tue","wed"...etc).
(NOTE: There are actually multiple instances of each day, and the data
is
read-in from a .dat file.)

I have no trouble at all with the actual number crunching, It is the
"proper" ordering of the factor that I am asking about. R first
alphabetizes
it("fri","mon","thu"...) before doing the work of lm(), aov() and
especially
plot().

I have tried as.ordered(factor( )), but that doesn't do anything.
If I re-assign levels() in the way that I want, that just renames the
the
levels of the factor but does not reorder it internally.
I've looked at chron(), but that seems to entail using a numeric vector
instead of a character vector.

How can I get it to "properly" (chronologically) order the factor. (In
some
ways I'm thinking that all I can do is:
days<- c("a.mon","b.tues","c.wed"...etc)

Thanks for all that you can do
Eric Jennings
matheric at u.washington.edu
matheric at myuw.net

______________________________________________
R-help at 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
9 days later
#
Thanks

That works great.

Eric

----- Original Message ----- 
From: <Bill.Venables at csiro.au>
To: <matheric at myuw.net>; <r-help at stat.math.ethz.ch>
Sent: Friday, April 15, 2005 10:42 PM
Subject: RE: [R] "chronological" ordering of factor in lm() and plot()


First put
then
will ensure the ordering you want.

Bill Venables.

-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Eric C. Jennings
Sent: Saturday, 16 April 2005 2:29 PM
To: R-help
Subject: [R] "chronological" ordering of factor in lm() and plot()


I am trying to do some basic regression and ANOVA on cycle times
(numeric
vectors) across weekdays (character vector), where I have simply
labelled my
days as:
days<- c("mon","tue","wed"...etc).
(NOTE: There are actually multiple instances of each day, and the data
is
read-in from a .dat file.)

I have no trouble at all with the actual number crunching, It is the
"proper" ordering of the factor that I am asking about. R first
alphabetizes
it("fri","mon","thu"...) before doing the work of lm(), aov() and
especially
plot().

I have tried as.ordered(factor( )), but that doesn't do anything.
If I re-assign levels() in the way that I want, that just renames the
the
levels of the factor but does not reorder it internally.
I've looked at chron(), but that seems to entail using a numeric vector
instead of a character vector.

How can I get it to "properly" (chronologically) order the factor. (In
some
ways I'm thinking that all I can do is:
days<- c("a.mon","b.tues","c.wed"...etc)

Thanks for all that you can do
Eric Jennings
matheric at u.washington.edu
matheric at myuw.net

______________________________________________
R-help at 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