I want to draw lines using a matrix with the X-axe on the first column, and the the Y-axe on the second column. These lines have to link the n points of a graph, so they are n-1, but the resout using these two commands: X <- matrix(scan("MaxInterEdges.R",0), ncol=2); lines(X[,1], X[,2], type = "l", col = "red"); is wrong, becose the lines are many more. What can I do? -- View this message in context: nabble.com/draw-n-1-lines-with-n-X-and-n-Y-tp25137514p25137514.html Sent from the R help mailing list archive at Nabble.com.
On Aug 25, 2009, at 12:15 PM, mirko86 wrote:> > I want to draw lines using a matrix with the X-axe on the first > column, and > the the Y-axe on the second column. > These lines have to link the n points of a graph, so they are n-1, > but the > resout using these two commands: > X <- matrix(scan("MaxInterEdges.R",0), ncol=2); > lines(X[,1], X[,2], type = "l", col = "red");?segments ... but I am a bit confused, because you need both an X and a Y for each pair of points.> is wrong, becose the lines are many more. > > What can I do?You _could_ post reproducible code. -- David Winsemius, MD Heritage Laboratories West Hartford, CT
Hi r-help-bounces at r-project.org napsal dne 25.08.2009 18:15:25:> > I want to draw lines using a matrix with the X-axe on the first column,and> the the Y-axe on the second column. > These lines have to link the n points of a graph, so they are n-1, butthe> resout using these two commands: > X <- matrix(scan("MaxInterEdges.R",0), ncol=2); > lines(X[,1], X[,2], type = "l", col = "red"); > > is wrong, becose the lines are many more. > > What can I do?Well, without reproducible code could help to identify a your problem. here is a guess X[,1] is not ordered and the lines are connecting points as they appear in your data. You could order X by first column and then try to plot lines. X.ord<-X[order(X[,1]),] lines(X.ord[,1], X.ord[,2], col = "red") Regards Petr> -- > View this message in context:nabble.com/draw-n-1-lines-with-n-X-> and-n-Y-tp25137514p25137514.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list > stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guideR-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code.