Ernesto Jardim wrote:> Hi
>
> When using "split" is it possible to keep then same ordering of
the
> factor on the output list ?
>
> Thanks
>
> EJ
>
There may be an easier way to do this but I would make the split
variable ordered before calling split. As in:
> d = data.frame(a = 1:4, b = c("d", "c"))
> sapply(d, data.class)
a b
"numeric" "factor"
> split(d$a, d$b)
$c
[1] 2 4
$d
[1] 1 3
> d$b = ordered(d$b, c("d", "c"))
> sapply(d, data.class)
a b
"numeric" "ordered"
> split(d$a, d$b)
$d
[1] 1 3
$c
[1] 2 4
>
Regards,
Sundar