0

I want to split the row wise pairs to column wise. merge or melt functions did not work. For instance, my dataset is like,

dt<-data.frame(ID=c(123,125), AgeX=c(23,30), AgeY=c(46,28))

and the expected result will have 2 columns in this example.

dt<-data.frame(ID=c(123,123,125,125), AgeX=c(23,46,30, 28))
Kodex
  • 23
  • 4
  • you said `melt` did not work (`merge` is wrong for this), how did you call it? Sometimes it's better to help you fix the code you tried. – r2evans Jul 30 '20 at 01:01
  • For me, it is working correctly `melt(dt, id.var = 'ID')[-2]` – akrun Jul 30 '20 at 01:02

0 Answers0