zhijie zhang wrote:
Hi,
 I have a data set with three variables,X Y and Time. X and Y are the
coordinates of points, i want to join these points according to the Time
sequence using arrows?
Demo Example data:
x<-c(1:6)
y<-c(1:6)
time<-c(6:1)
data<-cbind(x,y,time)
data
     x y time
[1,] 1 1    6
[2,] 2 2    5
[3,] 3 3    4
[4,] 4 4    3
[5,] 5 5    2
[6,] 6 6    1
  I hope to join the six points with points' time=1 as starting point and
points' time=6 as endpoint. So the sequence is time=1,2,3,4,5,6 and join the
corresponding points with arrows.
  Any ideas on it?


data <- data.frame(data[order(data[,"time"]),])
with(data, plot(y ~ x))
with(data, arrows(x[-length(x)], y[-length(x)], x[-1], y[-1]))


Uwe Ligges


        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to