I have been trying to use melt() function in r to shape my dataframe.
Here is the original,
group StartX StartY EndX EndY id
18878713 524897 180779 525352 179484 1
18884056 531199 183111 532538 182503 2
I want to shape it to this,
group Variable Value id
18878713 524897 180779 1
18884056 531199 183111 2
18878713 525352 179484 1
18884056 532538 182503 2
Any idea how I can do this? Thanks!
Here's another base R solution using
reshape(...)
.You can get rid of the
time
column withIf you insist on using
melt(...)
, which is not really designed for this type of problem, here is one way.