Eduardo Klein <eklein <at> usb.ve> writes: > I would like to know how R assigns the numeric code to a set of factors > in a vector. [snip] > It is indeed alphabetical by default. To get it in order of appearance you could do something like set.seed(1001) x <- sample(letters[1:5],50,replace=TRUE) f <- factor(x,levels=unique(x))