[R] Reordering a numeric variable

Bert Gunter gunter.berton at gene.com
Thu Dec 15 23:32:40 CET 2011

I believe this needs to be posted on general statistical help list
like stats.stackexchange.com
as you appear to have some confusion about how linear regression
works, especially with categorical variables.


might help you with R's way of dealing with the issues that I believe
you're asking about, but it may not make much sense if I'm correct
about your underlying misunderstanding. If I'm wrong, that and perhaps
?C will probably do it for you.

-- Bert

On Thu, Dec 15, 2011 at 1:44 PM, Abraham Mathew <abraham at thisorthat.com> wrote:
> I'm running a linear model in R using the car package.
> I have a variable education, which i have recoded and regrouped to my
> wishes.
> However, R seems to place each element of that variable in alphabetical
> order.
> When I am running the model, don't I need the model order from lowest to
> highest to make an inference that
> a one unit change in one variable produced a one unit change in another.
> levels(educ)
> educ2 = NA
> educ2[educ %in% levels(educ)[c(4,7)]] <- "HS or Some College"
> educ2[educ %in% levels(educ)[1:2]] <- "College Degree"
> educ2[educ %in% levels(educ)[c(3,5)]] <- "Advanced Degree"
> educ2[educ %in% levels(educ)[c(6,8)]] <- "Other"
> educ2 = factor(educ2)
> levels(educ2)
> The above code is how I regrouped the variable. How can I regroup it so
> that it's levels
> are from lowest to highest. What if they're numeric values"
> --
> *Abraham Mathew
> Statistical Analyst
> This or That Media, Inc.
> abraham at thisorthat.com
> 720-648-0108
> @abmathewks
> www.amathew.com
> *
>        [[alternative HTML version deleted]]
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.


Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374

More information about the R-help mailing list