Patrick Giraudoux H wrote:
Hi,
Would a specialist of the "point" or "plot" functions try the following:
mat<-matrix(c(1.836767,4.025989,0.6396777,0.3764444),ncol=2) plot(mat) points(mat[1,],col="red")
..A lag appears on x for mat [1,1] between the two displays.
I wonder if this example may be due to a bug or to the mis-use of a matrix in the plot() points() functions. In case of mise-use which kind can it be?
It's misuse:
For a matrix, the first column is interpreted as the x-coordinates, the second one as y-coordinates.
For a vector (mat[1,] is a (1D) vector!) plot/points plots the values (as y-coordinates) against their index (1:2 in this case, where 1 is not visible in the plot).
You can use
points(mat[1,,drop=FALSE], col="red")
in order not to drop dimensions, so mat[1,,drop=FASLE] is still a 2-column matrix.
Uwe Ligges
I am working with R 2.0.1 and Windows XP.
Cheers,
Patrick Giraudoux
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
______________________________________________ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
