Skip to content
Prev 284381 / 398502 Next

Reordering levels of a factor when the factor is part of a data frame

Hi Judith,

You should use double brackets, like this:

df[[variab]]<-factor(df[[variab]], levels=c("A2B","B31","C33"))

see ?"[" for details, noting that the help page assumes that you know
data.frames are list-like objects.

Best,
Ista
On Mon, Feb 6, 2012 at 2:03 PM, Judith Flores <juryef at yahoo.com> wrote: