Skip to content
Prev 4535 / 63421 Next

desiderata for data manipulation

rossini@blindglobe.net (A.J. Rossini) writes:
Almost, but not quite stack()/unstack()...

The basic cases of "reshape long" looks like it would be a piece of
cake to model over the subset() and stack() functions. "reshape wide"
looks a little more tricky, unless you want to brutally assume that
you're dealing with the result of a previous "reshape long".

(The problem would be that in principle you'd know what to do with

A B Y             
1 1 0.1           A Y1 Y2
1 2 0.3    ---->  1 0.1 0.3
2 1 0.7           2 0.7 0.9
2 2 0.9

but suppose there's a fifth line as in

A B Y  
1 1 0.1
1 2 0.3
2 1 0.7
2 2 0.9
2 2 1.1

Then you'd have two candidates for the value of Y2 for A==2 and it
wouldn't help to assume that there are really two cases with A==2,
because you can't really be sure about to which case the Y1 should
belong.)