Re: [R] modify particular factor levels

2011-04-15 Thread Dieter Menne
baptiste auguie-5 wrote: > > > I wish to modify programmatically only a few factor levels, according > to a named list. I came up with this function.. > > . > It seems to work, but the original order of the levels is changed. > > The split-and-unite policy you use makes it a bit diff

[R] modify particular factor levels

2011-04-14 Thread baptiste auguie
Dear list, I wish to modify programmatically only a few factor levels, according to a named list. I came up with this function, modify.levels <- function(f, modify=list()){ ## levels that will not be changed names.old.levels <- setdiff(levels(f), unlist(modify)) ## as a named list old.le