invictus invictus - 3 years ago 174
R Question

decreasing coefficients in R's coefplot?

has a variable
which when set to to
the coefficients should be plotted in descending order

But when I run a toy example:

data(tips, package = "reshape2")
mod1 <- lm(tip ~ day + sex + smoker, data = tips)
coefplot(mod1, decreasing = TRUE)

the coefficients aren't in descending order.

What am I missing?

enter image description here

Answer Source

You need to set sort = "magnitude":

coefplot(mod1, decreasing = TRUE, sort = "magnitude")

enter image description here

The default sorting is "natural", which is effectively 1:length(coef(mod1)).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download