I have a data frame with distances between start and end points. Start points are in rows, end points are in columns. Now I want to have them printed each one by one (startpoint endpoint distance newline). Missing values (NAs) should be omitted.
This is my data frame:
EndPoint
StartPoint TX001 TX002 TX003
TX002 37.4 NA NA
TX003 NA 14.78704 NA
TX005 NA NA 60.78947
What I want to get is:
TX002 TX001 37.4
TX003 TX002 14.78704
TX005 TX003 60.78947
Any help is greatly appreciated.
Sugi
If I’ve missed the mark, please use
dputto provide a sample of your data. However, assuming your data looks like this:You can use
meltfrom thereshape2package and then drop the extra rows withna.omit.