Skip to content
Prev 154692 / 398513 Next

ordered factor and table

Troels Ring wrote:
Hi Troels,

I suspect that your notion of "ordered factor" differs from the
technical one. Is the issue that you want ID to have the ordering of
levels as the order of appearance in your data? In that case, try
something like


within(labs, ID <- factor(ID, levels=unique(ID)))


As in:
[1] Crosby Stills Nash   Nash   Young
Levels: Crosby Nash Stills Young
[1] Crosby Stills Nash   Nash   Young
Levels: Crosby Stills Nash Young
ID
Crosby Stills   Nash  Young
     1      1      2      1